{"id":60,"date":"2011-07-14T09:23:17","date_gmt":"2011-07-14T09:23:17","guid":{"rendered":"https:\/\/sqlserverlearner.azurewebsites.net\/2011\/07\/14\/configure-sql-server-to-use-xp_cmdshell\/"},"modified":"2011-07-14T09:23:17","modified_gmt":"2011-07-14T09:23:17","slug":"configure-sql-server-to-use-xp_cmdshell","status":"publish","type":"post","link":"https:\/\/sqlserverlearner.com\/2011\/07\/14\/configure-sql-server-to-use-xp_cmdshell\/","title":{"rendered":"enable xp_cmdshell on SQL Server"},"content":{"rendered":"
How to enable xp_cmdshell on SQL Server 2005\/2008?<\/strong><\/p>\n If xp_cmdshell is disabled on SQL Server you get the following error: In order to enable this SQL Server has to be configured to allow access to procedure xp_cmdshell.<\/p>\n Following are the steps for that:<\/p>\n [sql] This enables to show advanced options by sp_configure.<\/p>\n Now if you execute sp_configure The following will be the output in the results window:<\/p>\n Run the following query to enable this: Now you will be able to execute xp_cmdshell.<\/p>\n
\nQuery:
\n[sql]
\nEXEC xp_cmdshell ‘dir’
\n[\/sql]<\/p>\n
\nSQL 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.
\n<\/font><\/p>\n
\nEXEC sp_configure ‘show advanced options’, 1
\nreconfigure
\nGO
\n[\/sql]<\/p>\n
\n[sql]
\nEXEC sp_configure
\n[\/sql]<\/p>\n<\/a>
\n[sql]
\nEXEC sp_configure ‘xp_cmdshell’,1
\nreconfigure
\nGO
\n[\/sql]<\/p>\n