For more information about enabling xp_cmdshell see Surface Area Configuration in SQL Server Books Online. – SQLSERVERLEARNER https://sqlserverlearner.com LEARN SQL SERVER ONLINE Thu, 14 Jul 2011 09:23:17 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.2 enable xp_cmdshell on SQL Server https://sqlserverlearner.com/2011/07/14/configure-sql-server-to-use-xp_cmdshell/ https://sqlserverlearner.com/2011/07/14/configure-sql-server-to-use-xp_cmdshell/#comments Thu, 14 Jul 2011 09:23:17 +0000 https://sqlserverlearner.azurewebsites.net/2011/07/14/configure-sql-server-to-use-xp_cmdshell/ How to enable xp_cmdshell on SQL Server 2005/2008?

If xp_cmdshell is disabled on SQL Server you get the following error:
Query:
[sql]
EXEC xp_cmdshell ‘dir’
[/sql]


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:

[sql]
EXEC sp_configure ‘show advanced options’, 1
reconfigure
GO
[/sql]

This enables to show advanced options by sp_configure.

Now if you execute sp_configure
[sql]
EXEC sp_configure
[/sql]

The following will be the output in the results window:

xp_cmdshell disabled
xp_cmdshell disabled

Run the following query to enable this:
[sql]
EXEC sp_configure ‘xp_cmdshell’,1
reconfigure
GO
[/sql]

Now you will be able to execute xp_cmdshell.

More about using sp_configure can be found here

]]>
https://sqlserverlearner.com/2011/07/14/configure-sql-server-to-use-xp_cmdshell/feed/ 2