Published on

February 4, 2017

How to Fix Blocked Access Error in SQL Server

Recently, one of my blog readers reached out to me with a question about a common error they encountered in SQL Server. It turns out that I hadn’t written a blog post about this particular error before, so I decided to address it in this article. In this blog post, we will discuss how to fix the “blocked access” error in SQL Server.

The error message that my reader received was as follows:

Msg 15281, Level 16, State 1, Procedure xp_cmdshell
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.

As the error message suggests, the issue is related to the ‘xp_cmdshell’ component being turned off as part of the security configuration. To resolve this error, we need to enable the ‘xp_cmdshell’ feature. Here is the solution:


-- We need to have this ON because xp_cmdshell is an advanced option.
EXEC sp_configure 'show advanced options', 1
GO

-- To update the currently configured values for sp_configure
RECONFIGURE WITH OVERRIDE
GO

-- Now, enable the feature.
EXEC sp_configure 'xp_cmdshell', 1
GO

-- To update the currently configured values for sp_configure
RECONFIGURE WITH OVERRIDE
GO

By executing the above query in SQL Server Management Studio, we can enable the ‘xp_cmdshell’ feature and resolve the blocked access error. After completing these steps, the ‘xp_cmdshell’ component should be available for use without encountering the previous error.

It is important to note that enabling ‘xp_cmdshell’ should be done with caution, as it allows executing operating system commands from within SQL Server. This feature should only be enabled if necessary and with proper security measures in place.

I hope this article has helped you understand how to fix the blocked access error in SQL Server. If you have any further questions or need additional assistance, feel free to reach out to me.

Click to rate this post!
[Total: 0 Average: 0]

Let's work together

Send us a message or book free introductory meeting with us using button below.