SQL Server – Backup database from Command Prompt using sqlcmd command

Introduction

Here, I will explain how to backup an SQL Server database from Command Prompt using sqlcmd utility

Step 1: Open Command Prompt and type sqlcmd -S localhostSQLServer2014 -U sa , then press enter. Here localhostSQLServer2014 is server name and sa is username.

sqlcmd command

Note : To backup database using Windows Authentication, type sqlcmd -S localhostSQLServer2014 -E and press enter and skip Step 2

Step 2: Type your password and press enter

SQLCMD Command

Step 3: Type BACKUP DATABASE Galaxy TO DISK=’D:dataGalaxy.bak’ and press enter.

SQLCMD

Step 4: Type GO and press enter

SQLCMD

Some common parameters of sqlcmd

Command Description
-S Server name
-U User name
-P Password
-E Use trusted connection
-i Input file
-o Output file
-q Command line query
-Q Command line query and exit

For more information about sqlcmd command please visit http://msdn.microsoft.com/en-us/library/ms162773.aspx

One thought on “SQL Server – Backup database from Command Prompt using sqlcmd command

  1. Pingback: SQL Server – Restore database from Command Prompt using sqlcmd command | DEEPAK SHARMA

Leave a Reply

Your email address will not be published. Required fields are marked *