Quantcast
Channel: Red Gate forums: SQL Backup 7
Viewing all articles
Browse latest Browse all 713

RE: Restore multiple databases in the same job

$
0
0
Here's an alternative:

Code:
DECLARE @exitcode int
DECLARE @sqlerrorcode int
DECLARE @sitename nvarchar(16)
DECLARE @sql nvarchar(1024)

SET @sitename = '<your value>'

SET @sql = '-SQL "RESTORE DATABASE ' + @sitename + ' FROM DISK = ''D:\SQLVMDEV10\' + @sitename + '\FULL\*.sqb'' SOURCE = ''' + @sitename + ''' LATEST_FULL
   WITH MOVE DATAFILES TO ''G:\VirtualRestore'' , MOVE LOGFILES TO ''G:\VirtualRestore'' ,
   MAILTO = ''ed.watson@swfwmd.state.fl.us'', RECOVERY, DISCONNECT_EXISTING,
   REPLACE , CHECKDB = ''ALL_ERRORMSGS, DATA_PURITY, EXTENDED_LOGICAL_CHECKS'', DROPDB'

EXEC master..sqlbackup @sql, @exitcode OUT, @sqlerrorcode OUT


Note that the SOURCE and LATEST_FULL options must come immediately after the DISK value.

Viewing all articles
Browse latest Browse all 713

Trending Articles