Executing a bat file inside a Stored Procedure using SQL server 2005
When i try to execute a bat file using xp_CMDShell, i am getting a message as not recognized command.
Following is the command i executed:
EXEC master..xp_CMDShell 'C:\Documents and Settings\adcxqcv\Desktop\PQA\sample.bat'
I got a message as follows:
'C:\Documents' is not recognized as an internal or external command,
operable program or batch file.
NULL
Any Suggestions. Let me know how to execute a bat file inside a Stored Procedure. I am new to SQl开发者_如何学编程 Server.
Thanks, Vinu
Put the path inside ""
EXEC master..xp_CMDShell '"C:\Documents and Settings\adcxqcv\Desktop\PQA\sample.bat"'
xp_cmdshell can be a bit picky on the long file names, you are using quotes and it isn't playing ball, double quotes can sometimes work but if it still doesn't want to play ball then try use the older 8.3 filename instead.
exec master..xp_cmdshell 'c:\docume~1\adcxqcv\Desktop\PQA\sample.bat'
Without parameter
exec(' xp_cmdshell ''C:\script\test.bat'); --your bat file location(path)
With parameter
exec(' xp_cmdshell ''C:\script\test.bat '+@ecistate+' '+@stateid+' '+@pcno+''''); --your bat file location(path)
Execute and enjoy the solution:)
精彩评论