The xp_cmdshell extended stored procedure allows a user to run OS commands from within the Database Engine. In order to execute the same we will need to enable xp_cmdshell. We can perform the same in the following two ways:
1. Using the SP_CONFIGURE Stored Procedure:
a. Open a New Query Window in SQL Server and execute the following SQL command in order to change the global configuration settings for the current server so that all the available options are displayed:
SP_CONFIGURE 'show advanced options', 1
b. Execute the following SQL Command in order to update the currently configured value of the configuration option changed with the SP_CONFIGURE system stored procedure:
RECONFIGURE
c. Execute the following SQL Command in order to display the global configuration settings for the current server:
SP_CONFIGURE
d. Check the config_value for xp_cmdshell. If the value is 0, then Execute the following SQL Command in order to enable the Stored Procedure:
SP_CONFIGURE 'xp_cmdshell', 1
e. Execute RECONFIGURE in order to update the currently configured value of the configuration Option.
2. Using SQL Server 2005 Surface Area Configuration:
Perform the following steps in order to enable xp_cmdshell from SQL Server 2005 Surface Area Configuration window:
a. Open SQL Server Surface Area Configuration :
Click On Windows Button --> All Programs --> Microsoft SQL Server 2005 --> Configuration Tools --> SQL Server Surface Area Configuration. |
![]() |
b. Click “Surface Area Configuration for Features”

c. Select the xp_cmdshell component on the left pane and put a check mark on the Enable xp_cmdshell checkbox on the right pane.

d. Click on the Ok Button and you have successfully enabled xp_cmdshell stored procedure on your SQL Server 2005.
