enable xp_cmdshell on SQL Server

Posted on : 14-07-2011 | By : Devi Prasad | In : Configuring SQL Server, SQL Errors, SQL Security, SQL Server Basics, SQLServerPedia Syndication

Share:

2


How to enable xp_cmdshell on SQL Server 2005/2008?

If xp_cmdshell is disabled on SQL Server you get the following error:
Query:

EXEC xp_cmdshell 'dir'


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

In order to enable this SQL Server has to be configured to allow access to procedure xp_cmdshell.

Following are the steps for that:

EXEC sp_configure 'show advanced options', 1
reconfigure
GO

This enables to show advanced options by sp_configure.

Now if you execute sp_configure

EXEC sp_configure

The following will be the output in the results window:

xp_cmdshell disabled

xp_cmdshell disabled

Run the following query to enable this:

EXEC sp_configure 'xp_cmdshell',1
reconfigure
GO

Now you will be able to execute xp_cmdshell.

More about using sp_configure can be found here

(Visited 160 times, 1 visits today)



References : Devi Prasad (sqlserverlearner.com)

Need Help On SQL Server?

Cannot Find Solution to your problem (or) If you are looking for some help on SQL Server. Dont worry Click Here to Post your question and solve your issue.


Do you like my blog?

If you liked reading this blog, please help spread the word by sharing this blog with your friends.




Comments (2)

great tip, thanks for sharing

one question; if i want to activate xp_cmdshell on sql2008 r2, how can i do that? because this procedure failed.
Thanks

Write a comment



Tags: , , , , , , , , , , , ,