Quantcast
Channel: CodeFari
Viewing all articles
Browse latest Browse all 265

How to Enable & Disable XP_CMDSHELL using SP_CONFIGURE in SQL Server

$
0
0


In this article we will know how to enable/disable xp_cmdshellusing sp_configure in SQL Server. xp_cmdshell use to import text file to SQL Server.

When I tried to import .txt file using xp_cmdshell to SQL Server found following error.

"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', search for 'xp_cmdshell' in SQL Server Books Online."

Here we have to enable xp_cmdshell in SQLServer.

Enable xp_cmdshell using sp_configure in SQL Server

To enable xp_cmdshell using sp_configure execute the following script.


UseMaster
GO

EXECmaster.dbo.sp_configure'show advanced options', 1
RECONFIGUREWITHOVERRIDE
GO

EXECmaster.dbo.sp_configure'xp_cmdshell', 1
RECONFIGUREWITHOVERRIDE
GO


Disable xp_cmdshell using sp_configure in SQL Server

To disable xp_cmdshell using sp_configure execute the following script.


UseMaster
GO

EXECmaster.dbo.sp_configure'show advanced options', 1
RECONFIGUREWITHOVERRIDE
GO

EXECmaster.dbo.sp_configure'xp_cmdshell', 0
RECONFIGUREWITHOVERRIDE
GO



Viewing all articles
Browse latest Browse all 265

Trending Articles