Today I will show you how to enable the Xp_CmdShell extended stored procedure in Sql Server 2005 and 2008.
Well normal error message you'll get when Xp_CmdShell is not enabled on your Sql Server and you to try execute some Windows commands using Xp_CmdShell is
Msg 15281, Level 16, State 1, Procedure xp_cmdshell, Line 1
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.
You can enable the Xp_CmdShell using 2 ways, either by executing T-sql statements or from
"Surface Area Configuration Manager". We'll see both of them.
A. Enable Xp_Cmdshell from Management Studio.
For enabling Xp_CmdShell from Management Studio you need to execute following code.
-- 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
B. Enable the Xp_CmdShell from "Surface Area Configuration Manager."
1. Click Start, point to Programs, point to Microsoft SQL Server 2005, point to Configuration Tools, and then click SQL Server Surface Area Configuration.
2. On the SQL Server 2005 Surface Area Configuration page, click Surface Area Configuration for Features.
3. Click on xp_cmdshell and tick on checkbox of "Enable the xp_cmdshell".
- Mangal Pardeshi.
Sunday, December 21, 2008
Subscribe to:
Post Comments (Atom)
how to enable it on a 2008 SQL server??? Can you please gimme the GUI method?
ReplyDeleteFor SQL Server 2008 R2
ReplyDeleteOpen SQL Server Management Studio
Right Click on the Server
Choose Facets
In the View Facets window choose Surface Area Configuration from the Facet dropdown
Change XPCmdShellEnabled to True.
From Understanding Surface Area Configuration http://msdn.microsoft.com/en-us/library/ms161956(v=sql.105).aspx
Thanks a lot Richard, it works for me.
ReplyDeleteFernandoG. Martín
Thanks a lot Richard it works for me.
ReplyDeleteKr,
FernandoG. Martín
me aparece el siguiente error
ReplyDeleteMens 15123, Nivel 16, Estado 1, Procedimiento sp_configure, Línea 78
The configuration option 'show advanced options´' does not exist, or it may be an advanced option.
Valid configuration options are:
Mens 15123, Nivel 16, Estado 1, Procedimiento sp_configure, Línea 78
The configuration option 'xp-cmdshell' does not exist, or it may be an advanced option.
Valid configuration options are:
DBCC execution completed. If DBCC printed error messages, contact your system administrator.
Configuration option 'show advanced options' changed from 1 to 0. Run the RECONFIGURE statement to install.
I concur. It works. :)
ReplyDeleteNice Article !
ReplyDeleteReally this will help to people of SQL Server Community.
I have also prepared small note on this, script to enable and disable xp_cmdshell in SQL Server.
http://www.dbrnd.com/2015/11/sql-server-script-to-enable-and-disable-xp_cmdshell-configuration/