This article is half-done without your Comment! *** Please share your thoughts via Comment ***
In this post, I am sharing a script to check, enable and disable XP_CMDSHELL in the SQL Server.
This script is handy for those professionals, who are interested in using command line utilities with SQL Server.
If you want to use command line tool, you should enable this XP_CMDSHELL configuration.
First, Check XP_CMDSHELL is enabled on the server:
1 2 3 |
SELECT CONVERT(INT, ISNULL(value, value_in_use)) AS ConfigValue FROM sys.configurations WHERE name = 'xp_cmdshell' ; |
Script to enable and disable XP_CMDSHELL:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
-- Enable advanced options to be changed. EXEC SP_CONFIGURE 'show advanced options', 1 GO RECONFIGURE GO -- Enable xp_cmdshell option. EXEC SP_CONFIGURE N'xp_cmdshell', 1 GO RECONFIGURE GO -- Disable xp_cmdshell option. EXEC SP_CONFIGURE 'xp_cmdshell', 0 GO RECONFIGURE GO -- Disable advanced options to be changed. EXEC SP_CONFIGURE 'show advanced options', 0 GO RECONFIGURE GO |