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'
![](https://images-blogger-opensocial.googleusercontent.com/gadgets/proxy?url=http%3A%2F%2F1.bp.blogspot.com%2F-Mcso7c0HJSg%2FVRxWx2Yp_OI%2FAAAAAAAAAUI%2Fx1HMb8tgQLo%2Fs1600%2Fenabled.png&container=blogger&gadget=a&rewriteMime=image%2F*)
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.