|
xp_cmdshell(1)
XP_cmdshell>xp_cmdshell 2000/tsqlref/basiCS/update_topic.gif"> 新增信息 - 2001 年 9 月
以操作系统命令行解释器的方式执行给定的命令字符串,并以文本行方式返回任何输出。授予非管理用户执行 xp_cmdshell 的权限。 说明 在 Microsoft® Windows® 98 操作系统中执行 xp_cmdshell 时,将不把 xp_cmdshell 的返回代码设置为唤醒调用的可执行文件的进程退出代码。返回代码始终为 0。 语法xp_cmdshell {'command_string'} [, no_output]
参数'command_string' 是在操作系统命令行解释器上执行的命令字符串。command_string 的数据类型为 varchar(8000) 或 nvarchar(4000),没有默认值。command_string 不能包含一对以上的双引号。如果由 command_string 引用的文件路径或程序名称中有空格,则需要使用一对引号。如果使用嵌入空格不方便,可考虑使用 FAT 8.3 文件名作为解决办法。 no_output 是可选参数,表示执行给定的 command_string,但不向客户端返回任何输出。 返回代码值0(成功)或 1(失败) 结果集执行下列 xp_cmdshell 语句将返回当前目录的目录列表。 xp_cmdshell 'dir *.exe'
行以 nvarchar(255) 列的形式返回。 执行下列 xp_cmdshell 语句将返回随后的结果集: xp_cmdshell 'dir *.exe', NO_OUTPUT
下面是结果: The command(s) completed sUCcessfully.
注释
|