You can enable or disable xp_cmdshell by using the Policy-Based Management or by executing sp_configure. This option enables system adms to control wheather the xp_cmdshell extended stored procedure can be executed on a system.
By default this is option is disabled on a new installation.
How to enable:
-- 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
-- Enable xp_cmdshell feature
EXEC sp_configure 'xp_cmdshell', 1;
GO
-- To update the currently configured value for this feature.
RECONFIGURE;
GO
** User might receive below errow when excuting sp_configure command
EXEC sp_configure ‘show advanced options’,1
GO
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '‘'.
Note that the syntax is correct, but you might have used wrong character quote.
Run below query to check feature ENABLED or not.
SELECT * FROM SYS.CONFIGURATIONS WHERE Name = 'xp_cmdshell'
How to disable:
-- 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
-- Disable xp_cmdshell feature
EXEC sp_configure 'xp_cmdshell', 0
GO
-- To update the currently configured value for this feature.
RECONFIGURE
GO
Run below query to check feature DISABLED or not.
SELECT * FROM SYS.CONFIGURATIONS WHERE Name = 'xp_cmdshell'
** Users might receive below error when executing RECONFIGURE command.
Msg 5808, Level 16, State 1, Line 1
Ad hoc update to system catalogs is not supported.
Note that some configuration options require a server stop and restart to update the currently running value." By using “WITH OVERRIDE” you should be able to run successfully.
RECONFIGURE WITH OVERRIDE;
GO
Command(s) completed successfully.
http://www.sqlserver-expert.com/2015/04/enable-and-disable-xpcmdshell-using.html
Enable and Disable xp_cmdshell using SP_CONFIGURE
'Database > MS-SQL' 카테고리의 다른 글
sql 1일차 (0) | 2016.09.20 |
---|---|
[스크랩] MSSQL 연결테스트 - UDL 파일 이용 (0) | 2016.08.27 |
MSSQL 로그인 삭제시 DB 매핑 제외후 삭제필요 (0) | 2016.06.14 |
mssql에서 사용자 세션은 52번부터이다!! (0) | 2016.05.23 |
[스크랩] MSSQL DATABASE SHRINK 축소 (0) | 2016.04.22 |