Tuesday, 7 February 2017

Enable XP_CMDSHELL [SQLSTATE 42000] (Error 15281)


Below error clearly states that stored procedure tries to execute 'xp_cmdshell'. 

By default 'xp_cmdshell' is in disabled state. Enabling 'xp_cmdshell' resolved this error.


Executed as user: Domain\Login_User. 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. [SQLSTATE 42000] (Error 15281).  The step failed.



Enable ‘xp_cmdshell’ in T-SQL

-          Show advanced options
EXEC sp_configure 'show advanced options', 1;
GO
RECONFIGURE
GO

-          Enable xp_cmdshell
EXEC sp_configure 'xp_cmdshell', 1
GO
RECONFIGURE
GO


Enable ‘xp_cmdshell’ in SSMS

Right click on instance and select ‘Facets’.



Select ‘Surface Area Configuration’ next to Facet drop down.


Change the Facet Property ‘XPCmdShellEnabled’ to True. Click Ok.




No comments:

Post a Comment