2011-08-11 37 views
4

當我嘗試使用xp_CMDShell執行bat文件時,我收到一條消息爲未識別的命令。使用SQL服務器在存儲過程中執行bat文件2005

以下是我執行命令:

EXEC master..xp_CMDShell 'C:\Documents and Settings\adcxqcv\Desktop\PQA\sample.bat' 

我得到的消息如下:

'C:\Documents' is not recognized as an internal or external command, 
operable program or batch file. 
NULL 

任何建議。讓我知道如何在一個存儲過程中執行一個bat文件。 我是SQl Server的新手。

感謝, Vinu

回答

5

把裏面的路徑「」

EXEC master..xp_CMDShell '"C:\Documents and Settings\adcxqcv\Desktop\PQA\sample.bat"' 
2

xp_cmdshell的可以上長文件名有點挑剔,你正在使用引號,它是不是在玩球,雙引號有時可以工作,但如果它仍然不想玩球,那就試着使用舊的8.3文件名。

exec master..xp_cmdshell 'c:\docume~1\adcxqcv\Desktop\PQA\sample.bat'