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

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:

SELECT spresults.* 
FROM OPENROWSET('SQLNCLI', 'Server=192.168.0.7;Trusted_Connection=yes;',
                ' Exec DBPharmaUltimus.dbo.uspMIS_ExportSalesData ''2015-07-28''') AS spresults

July 29th, 2015 3:27am

Error appears because Ad Hoc Distributed Queries configuration parameter is disabled.

To enable Ad Hoc Distributed Queries follow the next steps:

First, make sure that you can see all SQL configuration settings when running sp_configure command by enabling the 'show advanced options' configuration parameter:

view plaincopy to clipboardprint?
  1. sp_configure 'show advanced options',1  
  2. reconfigure  

After this, enable the 'Ad Hoc Distributed Queries' by running the following statements:

view plaincopy to clipboardprint?
  1. sp_configure 'Ad Hoc Distributed Queries',1  
  2. reconfigure  

Executing sp_configure command you can see that the parameter is enabled:

 Ref:

Free Windows Admin Tool Kit Click here and download it now
July 29th, 2015 3:30am

Hello,

And also here a pretty clear error message: By security distributes ad hoc querys are disable; contact your DBA if it's required to change this.

July 29th, 2015 3:33am

If you have sysadmin permission, you can change this with sp_configure. If you are not sysadmin, you will need to talk kindly with your DBA:

Free Windows Admin Tool Kit Click here and download it now
July 29th, 2015 3:37am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics