SQL Server blocked access to procedure 'sys.xp_cmdshell'

SQL Server blocked access to procedure 'sys.xp_cmdshell' of component 'xp_cmdshell' because this component is turned off as part of the security configuration for this server. system administrator can enable the use of 'xp_cmdshell' by using sp_configure. For more information about enabling 'xp_cmdshell', see "Surface Area Configuration" in SQL Server Books Online.

---------------------------------------------------------------------------------------------------------------------

【解决办法】:
  1、通过SQL语句开启。[推荐此方法,因为在任何版本的SQL SERVER中都可以使用。]
  通过查询分析器,选择Master数据库,然后执行以下SQL内容:

sp_configure 'show advanced options',1
reconfigure
go
sp_configure 'xp_cmdshell',1
reconfigure
go

  执行结果:

  配置选项 'show advanced options' 已从 0 更改为 1。请运行 RECONFIGURE 语句进行安装。
  配置选项 'xp_cmdshell' 已从 0 更改为 1。请运行 RECONFIGURE 语句进行安装。

  如需关闭只需将“sp_configure 'xp_cmdshell',1”改为“sp_configure 'xp_cmdshell',0”即可。

 

  2、通过"SQL SERVER外围应用配置器"开启。[如果记代码困难,那就用此方法吧。]

  找到开始 --> SQL安装目录 --> 配置 SQL server managerment 外围应用配置器。如图:

SQL <wbr>Server <wbr>blocked <wbr>access <wbr>to <wbr>procedure <wbr>'sys.xp_cmdshell'

  打开后。找到并点击“功能的外围应用配置器”。

SQL <wbr>Server <wbr>blocked <wbr>access <wbr>to <wbr>procedure <wbr>'sys.xp_cmdshell'

  再打开的窗口中点击最下面的 xp_cmdshell然后点击右边的启用即可。

SQL <wbr>Server <wbr>blocked <wbr>access <wbr>to <wbr>procedure <wbr>'sys.xp_cmdshell'

 

  打开后,找到“xp_cmdshell”点击启用。



原文地址:https://www.cnblogs.com/liuzhuqing/p/7480117.html