Comments
2 comments
-
If you're using SQL Backup 6.3 or newer, try this:
EXEC master..sqlbackup '-sql "RESTORE DATABASE [table_backup] FROM DISK = [M:\SQL Backups\test_folder\FULL_table_backup_*.sqb] LATEST_FULL WITH RECOVERY, DISCONNECT_EXISTING, REPLACE" '
If you're using 6.2 or older, try this:DECLARE @cmd NVARCHAR(1024) DECLARE @dbfilename NVARCHAR(256) SET @dbfilename = '<your backup file name>' SET @cmd = '-sql "RESTORE DATABASE [table_backup] FROM DISK = [' + @dbfilename + '] WITH RECOVERY, DISCONNECT_EXISTING, REPLACE"' EXEC master..sqlbackup @cmd
-
Wow! Thanks, that's a MUCH better way than what I was doing!
Add comment
Please sign in to leave a comment.
EXECUTE master..sqlbackup '-SQL "RESTORE DATABASE [table_backup] FROM DISK = ''M:\SQL Backups\test_folder\FULL_table_backup_20110104_085509.sqb'' WITH RECOVERY, DISCONNECT_EXISTING, REPLACE, ORPHAN_CHECK"'
Can I replace that with the variable name? Is there something special I have to do to accomplish this? Am I missing a much better way to do this? I am using the default backup format with the name and date, so I could not see how to just use the restore script as it stands.
Any input is appreciated.