Formulation of SQLBackup Restore Command with variables
CWInfrastructure
Posts: 2 New member
in SQL Backup
I'm trying to restore logs into a SQL database. I'm trying to pass a variable for the log file location but I'm receiving an 850 error which apparently is a Syntax Error. I've tried all varieties of single quote marks in various different places even though I don't believe quotes are required here.
If I pass the full path without the variable the restore works fine. The screen shot shows the variable's contents which matches the full path. Could anyone offer the correct syntax to try please. I'm assuming SQL Backup Pro allows the passing of variables into a restore.
If I pass the full path without the variable the restore works fine. The screen shot shows the variable's contents which matches the full path. Could anyone offer the correct syntax to try please. I'm assuming SQL Backup Pro allows the passing of variables into a restore.
Best Answer
-
CWInfrastructure Posts: 2 New memberThanks to the following I've resolved it :
https://forum.red-gate.com/discussion/2824/using-variables-with-restore-command
The correct syntax is :
SET @TSQLArgs = '-SQL "RESTORE LOG [workdb] FROM DISK = ''' + @LogFileToRestore + ''' WITH RECOVERY"';