sp_cmdShell

作用:生成 Windows 命令 shell 并以字符串的形式传递以便执行。任何输出都作为文本的行返回。

使用方法:xp_cmdshell { 'command_string' } [ , no_output ]

 

xp_cmdshell可以让系统管理员以操作系统命令行解释器的方式执行给定的命令字符串,并以文本行方式返回任何输出,是一个功能非常强大的扩展存贮过程。一般情况下,xp_cmdshell对管理员来说也是不必要的,xp_cmdshell的消除不会对Server造成 任何影响。可以将xp_cmdshell消除:
 

   Use Master
   Exec sp_dropextendedproc N’xp_cmdshell’
   Go


   如果需要的话,可以把xp_cmdshell恢复回来:


   Use Master
   Exec sp_addextendedproc N’xp_cmdshell’, N’xplog70.dll’
   Go

 

SQL Server 2005 中引入的 xp_cmdshell 选项是服务器配置选项,使系统管理员能够控制是否可以在系统上执行 xp_cmdshell 扩展存储过程。默认情况下,xp_cmdshell 选项在新安装的软件上处于禁用状态,但是可以使用基于策略的管理或运行 sp_configure 系统存储过程来启用它,如下面的代码示例所示:

-- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1
GO
-- To update the currently configured value for advanced options.
RECONFIGURE
GO
-- To enable the feature.
EXEC sp_configure 'xp_cmdshell', 1
GO
-- To update the currently configured value for this feature.
RECONFIGURE
GO

posted @ 2009-11-26 11:18  db's jim  阅读(257)  评论(0编辑  收藏  举报