0

I am new to SqlCmd. Can anyone give a short explanation of the following command?

SQLCMD -S VMLIVE-DATA\SQLSERVER -Q 
"RESTORE DATABASE GIS_ENG FROM DISK = N'\\10.143.251.101\ClientData\Backup\DatabaseBackups\DB_ENG.bak' 
WITH  FILE = 1, 
MOVE N'DB_ENG' TO N'\\10.153.201.11\E$\SQLSERVER\Data\DB_ENG.mdf', 
MOVE N'DB_ENG_log' TO N'\\10.153.201.11\E$\SQLSERVER\Data\DB_ENG.ldf',  
NOUNLOAD,  REPLACE,  STATS = 10"
2

Sure it is saying to use SQLCMD.EXE connecting to the server instance VMLIVE-DATA\SQLSERVER, to run the script that will restore the GIS_ENG from a backup of the DB_ENG database, replacing the existing GIS_ENG if there is one.

The bulk of the text is the script -Q"RESTORE ... STATS=10".

The SQLCMD and RESTORE DATABASE parameters are define in the SQL Server documentation.

SQLCMD.EXE - http://technet.microsoft.com/en-us/library/ms162773.aspx

RESTORE DATABASE - http://technet.microsoft.com/en-us/library/ms186858.aspx

By default SQLCMD uses Trusted Connections (describe in the SQLCMD link) so it requires this to be run by a login with rights to restore a database.

  • What about this line "NOUNLOAD, REPLACE, STATS = 10" – Nav Ali Sep 28 '13 at 19:32
  • NOUNLOAD means do not unload a tape. Commonly included in scripts, but hardly anybody uses tape anymore, so it is a NoOp. REPLACE forced the DB_ENG backup being restored to replace the existing GIS_ENG database as a new GIS_ENG database. STATS=10 defines what monitoring of the restore gets reported. In this case, every 10%. This is in the RESTORE link above or in linked topics connecting on BACKUP and RESTORE. – RLF Sep 28 '13 at 19:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.