Using the return value of a SQL Restore script
0
Q:
Using the return value of a SQL Restore script
I am trying to use the return value of a SQL Restore script executed with SQLCMD, so that my batch script can report on the succes or failure of the restore. I am having difficulty getting the script to return the result of the backup or restore process. Do you have any suggestions?

The follwoing succesfully restores the database but returns a -100 error code:
SQLCMD -S SERVERNAME -Q "exit(RESTORE DATABASE [PremiumAutomation] FROM  DISK = N'C:SQLBackupsHotBackupPremiumAutomationRest.bak' WITH  FILE = 1,  NOUNLOAD,  REPLACE,  STATS = 10)" -o FolderNameRestore.Log
ASKED: Mar 16 2009  5:34 PM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
15 pts.
0
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0
  • AddThis Social Bookmark Button
You can use SQLCMD -b to return a nonzero exit code when the SQL batch fails.
You can then check the ERRORLEVEL in the batch to determine if the outcome was succesfull
Last Answered: Mar 20 2009  11:27 AM GMT by FransG   15 pts.
Latest Contributors: Mrdenny   46795 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



0