sql server - Return value of SQLCMD RESTORE in cmd batch -
i building cmd script restore sql server database, , need know if restore worked correctly, in order perform other tasks. code:
sqlcmd -s %database_server% -u user-p password-q "restore database %database% disk='i:\bakup.bak'"
thanks
backup command doesn't return error code. moreover, backup error can found in error log only, not in of system catalogs.
there table msdb.dbo.backupset
information on successful backups, though, , can used deduce whether backup errored or not.
make note of current time prior taking backup, , after backup finishes use query retireve time of last successful backup:
select max(backup_start_date) msdb.dbo.backupset database_name = 'database_name'
if time returned less 1 recorded there errors.
Comments
Post a Comment