启用'xp_cmdshell'SQL Server


176

我要执行 EXEC master..xp_cmdshell @bcpquery

但是我收到以下错误:

SQL Server禁止访问组件“ xp_cmdshell”的过程“ sys.xp_cmdshell”,因为该组件的安全配置已关闭此组件。系统管理员可以使用sp_configure启用“ xp_cmdshell”的使用。有关启用“ xp_cmdshell”的更多信息,请参见SQL Server联机丛书中的“曲面区域配置”。

有什么方法可以激活它,或者在启用该功能之前执行一些操作?

怎么解决呢?

Answers:


369

您需要启用它。查看xp_cmdshell MSDN文档的Permission部分:

http://msdn.microsoft.com/en-us/library/ms190693.aspx

-- 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

2
确实有效,简单又有效!
indofraiser

2
确保以管理员身份执行SQL Management Studio
Haim Raman

感谢您的大力帮助。寻找几天的解决方案。
Mohan Rajput,

2
安全 -启用但要小心!请记住:
sawyer
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.