Scheduled Restored (with multiple databases) in same job
I have setup a scheduled restore job within SQL Backup, though would like to know if there is a simpler way of selecting multiple databases within the same job, rather than creating 10 separate jobs for the 10 databases I have.
All test database files are in the same folder and going to the same database the only parameter that is different is the database name.
declare @exitcode int
DECLARE @sqlerrorcode int
EXECUTE master..sqlbackup '-SQL "RESTORE DATABASE b]<dBName>[/b FROM DISK = ''\serverArchive*.sqb'' SOURCE = ''<dBName>'' LATEST_FULL WITH RECOVERY, DISCONNECT_EXISTING, MOVE DATAFILES TO ''F:Temp'', MOVE LOGFILES TO ''F:Temp'', REPLACE, ORPHAN_CHECK, CHECKDB = ''NO_INFOMSGS, ALL_ERRORMSGS''"', @exitcode OUT, @sqlerrorcode OUT
IF (@exitcode >= 500) OR (@sqlerrorcode <> 0)
RAISERROR ('SQL Backup failed with exit code: %d SQL error code: %d', 16, 1, @exitcode, @sqlerrorcode)
I have achieved this by copying the above block 10 times and changing the <dBName> to suit, messy I know, is there a way I can set a table variable and pass/iterate the 10 database names into one block or can the GUI have this and I am missing something