Enable XP_cmdshell in SQL Server 2008

Monday, May 4, 2009 |

XP_CMDSHELL is very useful extended stored procedure in Microsoft SQL Server 2008 which will give you power to run command as an operating system power shell. By default it is disabled in any Microsoft SQL server version due to security reasons but you can enable it for your need. Herewith, I am giving you T-SQL commands to enable it.

--list all setting which you can configure with SP_Configure stored procedure
--you may not be able to see XP_CMDSHELL command in the list.
EXECUTE SP_CONFIGURE
--see full list of command by making show advanced options ON
EXECUTE SP_CONFIGURE 'show advanced options', 1
RECONFIGURE WITH OVERRIDE
GO
--enable xp_cmdshell command
EXECUTE SP_CONFIGURE 'xp_cmdshell', '1'
RECONFIGURE WITH OVERRIDE
GO

Reference: Ritesh Shah
http://www.sqlhub.com
Note: Microsoft Books online is a default reference of all articles but examples and explanations prepared by Ritesh Shah, founder of http://www.SQLHub.com

0 comments: