SQL 2000中的xp_cmdshell提示错误
declare @query varchar(1000)
set @query = master.dbo.xp_cmdshell "dir c:\input /b"
错误提示:
服务器:消息 170,级加15,状态 1,行2
第2行:'dir c:\input /b"附个有误法错误
单独执行:
EXEC master.dbo.xp_cmdshell "dir c:\input /b"
或
master.dbo.xp_cmdshell "dir c:\input /b"
可以正确返回结果.
[解决办法]
declare @query varchar(1000)
set @query = 'master.dbo.xp_cmdshell "dir c:\input /b"' --单引号
PRINT @query