Msg 15281, Level 16, State 1, Line 2 SQL Server blocked access to STATEMENT 'OpenRowset/OpenDatasource' of component 'Ad Hoc Distributed Queries' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ad Hoc Distributed Queries' by using sp_configure. For more information about enabling 'Ad Hoc Distributed Queries', search for 'Ad Hoc Distributed Queries' in SQL Server Books Online.
To overcome this issue, There are two methods, One is by using SQL Server Management Studio GUI interface and Other is by running Stored Procedures to enable program.
Run Following Stored Procedures:
Method 1
EXEC sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
EXEC sp_configure 'Ad Hoc Distributed Queries', 1;
GO
RECONFIGURE;
Explanation:
Here sp_configure displays or changes global configuration settings for the current server.
By setting Show Advanced options to 1, we can list the advanced options by using sp_configure. The default is 0.
By Enabling Show Advanced options, we can Enable Ad Hoc Distributed Queries options.
Ad Hoc Distributed Queries: By default, SQL Server does not allow ad hoc distributed queries using OPENROWSET and OPENDATASOURCE. When this option is set to 1, SQL Server allows ad hoc access.
To enable Ad Hoc Distributed Queries then prior to this, we need to enable Show Advanced options in sp_configure stored procedure.
RECONFIGURE:
Updates the currently configured value (the config_value column in the sp_configure result set) of a configuration option changed with the sp_configure system stored procedure.
Because some configuration options require a server stop and restart to update the currently running value, RECONFIGURE does not always update the currently running value (the run_value column in the sp_configure result set) for a changed configuration value.
We can use SERVER CONFIGURATION Option present in SQL Server Management Studio.
In SQL Server 2012, SERVER CONFIGURATION can be found by Right click on Server and selecting FACETS option.
Check the snippet.
Next From FACETS option, Select SERVER CONFIGURATIONS.
Now Select TRUE from Drop Down Option from AdHocRemoteQueriesEnabled as shown in Snippet below and Give Ok. Now the error is eliminated.
RECONFIGURE:
Updates the currently configured value (the config_value column in the sp_configure result set) of a configuration option changed with the sp_configure system stored procedure.
Because some configuration options require a server stop and restart to update the currently running value, RECONFIGURE does not always update the currently running value (the run_value column in the sp_configure result set) for a changed configuration value.
We can use SERVER CONFIGURATION Option present in SQL Server Management Studio.
In SQL Server 2012, SERVER CONFIGURATION can be found by Right click on Server and selecting FACETS option.
METHOD 2
Check the snippet.
Next From FACETS option, Select SERVER CONFIGURATIONS.
Now Select TRUE from Drop Down Option from AdHocRemoteQueriesEnabled as shown in Snippet below and Give Ok. Now the error is eliminated.
Comments
Post a Comment