Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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"
share|improve this question

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer
    
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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