I am trying to run a simple batch file that calls a backup script I have in SQL Server. When I enter this into a command line, it works but when run from a .bat file, nothing happens. No errors, no output at all.
sqlcmd.exe -S WIN-FPQSHCEB0EM -E -Q "EXEC sp_BackupDatabases @backupLocation='E:\Backups\', @databaseName=’xxxxxx’, @backupType='F'"
PAUSE
Any idea why this wouldn't work?
I know this is an old question, but it happened to me recently!
Its because of the quote marks in your SQL... I couldn't find a method to escape them, so I resorted to using a script file.. Put your SQL into the script file, then use the "-i " to run that, instead of inline SQL...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With