I am trying to use xp_cmdshell for the first time.
When I run the following command in a cmd window on the server it works. (it just calls a third party tool that takes backups)
"C:\BackupScripts\Backup.bat" "FULL" "SSDBSERV\L008" "MH" "SQL_UAT"
"C:\BackupScripts\Backup.bat" "FULL" "SQL01" "MH" "SQL_UAT"
Now im trying to execute it via sql using xp_cmdshell so im running:
exec master.dbo.xp_cmdshell '"C:\BackupScripts\Backup.bat" "FULL" "SQL01" "MH" "SQLUAT"'
but I get the error:
The system cannot find the path specified.
Does the xp_cmdshell command handle the quotations funny? Am I doing something wrong?
Is C:\BackupScripts\Backup.bat a local path in your client machine? Is sql server installed in another machine? Also are you using an account with sysadmin priviledges?
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
1) The batch file resides on a different machine from which SQL Server is running from.
2) The BAT file includes a relative path, for instance ..\TEMP which does not exist from the default folder for xp_cmdshell (which is C:\Windows\Syste32).
Erland Sommarskog, SQL Server MVP, email@example.com
I've just installed SSMS on the server and ran it from there directly.
Now I get a different error:
'C:\BackupScripts\Backup.bat" "FULL" "SQL01" "MH" "SQL_UAT' is not recognized as an internal or external command,
It looks like its dropping the double quotation marks at the beginning and end of the command...