This article outlines the steps to Enable and Disable XP_CMDSHELL using the SP_CONFIGURE system stored procedure.
While running a SQL script that uses XP_CMDSHELL extended stored procedure, are you getting the following error?
Use Master
GO
EXEC sp_configure 'show advanced options', 1
RECONFIGURE WITH OVERRIDE
GO
EXEC sp_configure 'xp_cmdshell', 1
RECONFIGURE WITH OVERRIDE
GO
Once XP_CMDSHELL is enabled, let’s run the below script to copy files from the source(C:\Azure) to the destination (C:\AzureCopy) directory.
xp_cmdshell 'copy C:\Azure C:\AzureCopy';
The t-SQL script to disable the XP_CMDSHELL in SQL Server is as below:
Use Master
GO
EXEC sp_configure 'show advanced options', 1
RECONFIGURE WITH OVERRIDE
GO
EXEC sp_configure 'xp_cmdshell', 0
RECONFIGURE WITH OVERRIDE
GO
Commenti