This is what the backupdb.sql looked like:
BACKUP DATABASE $(database) TO DISK = $(backupfilename)
I then executed the following sqlcmd command:
sqlcmd -S localhost -i BackupDb.sql -v database="mydb" -v backupfilename="mydb.bak"
sqlcmd -S localhost -i BackupDb.sql -v database="mydb" -v backupfilename="E:\sqlbackups\mydb.bak"
This time I got the following error:
Msg 102, Level 15, State 1, Server ANDREW-PC, Line 3 Incorrect syntax near 'E:'.
After a lot of fiddling around I figured out what I needed to do to fix the problem. The problem was that the backupfilename needs to be unicode. See below for the fixed backupdb.sql
BACKUP DATABASE $(database) TO DISK = N'$(backupfilename)'
No comments:
Post a Comment