{"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:
\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

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]
\nEXEC sp_configure ‘show advanced options’, 1
\nreconfigure
\nGO
\n[\/sql]<\/p>\n

This enables to show advanced options by sp_configure.<\/p>\n

Now if you execute sp_configure
\n[sql]
\nEXEC sp_configure
\n[\/sql]<\/p>\n

The following will be the output in the results window:<\/p>\n

\"xp_cmdshell<\/a>
xp_cmdshell disabled<\/figcaption><\/figure>\n

Run the following query to enable this:
\n[sql]
\nEXEC sp_configure ‘xp_cmdshell’,1
\nreconfigure
\nGO
\n[\/sql]<\/p>\n

Now you will be able to execute xp_cmdshell.<\/p>\n

More about using sp_configure can be found here<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"

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…<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32,128,101,41,3],"tags":[160,161,162,163,164,165,166,167,168,169,170,171,172],"_links":{"self":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts\/60"}],"collection":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/comments?post=60"}],"version-history":[{"count":0,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts\/60\/revisions"}],"wp:attachment":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/media?parent=60"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/categories?post=60"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/tags?post=60"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}