Why does xp_cmdshell not work in SQL Server 2012?

Possible duplicate:
Enable 'xp_cmdshell SQL Server

When I run the xp_cmdshell command in SQL Server 2012, I get the following message:

SQL Server blocked access to the 'sys.xp_cmdshell' procedure of the 'xp_cmdshell' component because this component is disabled as part of the security configuration for this server. The system administrator can enable the use of 'xp_cmdshell' using sp_configure. For more information about enabling xp_cmdshell, search for xp_cmdshell in SQL Server Books Online.

But in SQL Server 2000, this query is successful.

+6
source share
2 answers

This is out of the box since SQL Server 2005 when they introduced the Surface Area Customizer to make SQL Server more secure by default. Since then, this tool has retired, but you can still control behavior using sp_configure . An example is shown on MSDN :

 -- To allow advanced options to be changed. EXEC sp_configure 'show advanced options', 1 GO -- To update the currently configured value for advanced options. RECONFIGURE GO -- To enable the feature. EXEC sp_configure 'xp_cmdshell', 1 GO -- To update the currently configured value for this feature. RECONFIGURE GO 

(I also wrote about this many years ago .)

The reason is that this is a potential security hole. If you allow SQL Server to run xp_cmdshell , then they theoretically can send any command to the operating system, bypassing any security that you thought about. This is especially problematic when the SQL Server service account and / or proxy account are upgraded to a system administrator or other levels, because it is easier than directly identifying only the exact things that they need to do.

Instead of turning it on and off to support command line interaction, a popular way to expose the functionality of an operating system, although it controls security, is to implement the OS level functionality you need using SQL-CLR. Here is a good starting point for accessing the file system with the CLR (however, if you search around you will find much more modern and comprehensive approaches).

+19
source

This is disabled for SQL Server 2012. But you can run the following command in SQL Server 2008.

 EXEC sp_configure 'xp_cmdshell', 1 RECONFIGURE 
+3
source

All Articles