I tried running the sqlcmd from a remote host to do a simple backup of a sql 2008 database. The command goes something like this:
sqlcmd -s xxx.xxx.xxx.xx -U username -P some_password -Q "Backup database [db] to \
disk = 'c:\test_backup.bak' with format"
I get a succesfull message but the file isn't created.
When I run this on the sql manager on the same machine, it works. I thought it was permission problems, but I'm using the same username in both cases.
Any thoughts?
Best Answer
Follow this guide .
You need to create a SQL script that backup the database specified in it on the desired location, then you can call that sql script from SQLCMD .
For example if you call the backup script backup.sql :
Example of backup.sql :