Competition: What’s your favorite Redgate tool? Enter now.

Using variables with Restore command

BetelgeuseBetelgeuse Posts: 9
edited July 20, 2006 1:58PM in SQL Backup Previous Versions
I want to automate the restore of a database from the latest backup file in a directory with multiple backup files. I can determine the name of this file from msdb but I need to pass the name of the file to the restore command as a variable. The following syntax works with MSSQL restore but not SQL Backup restore:

restore database TEST from disk = @BackupFileName ....

EXEC master..sqlbackup N'-SQL "RESTORE DATABASE [TEST] FROM DISK = @BackupFileName ....
SQL Backup v4.5.704
Syntax error: '@BackupFileName' after '='



Sign In or Register to comment.