{"id":56,"date":"2011-07-11T07:52:58","date_gmt":"2011-07-11T07:52:58","guid":{"rendered":"https:\/\/sqlserverlearner.azurewebsites.net\/2011\/07\/11\/enable-openrowset\/"},"modified":"2011-07-11T07:52:58","modified_gmt":"2011-07-11T07:52:58","slug":"enable-openrowset","status":"publish","type":"post","link":"https:\/\/sqlserverlearner.com\/2011\/07\/11\/enable-openrowset\/","title":{"rendered":"Enable OPENROWSET"},"content":{"rendered":"
When you try to execute queries involving OPENROWSET on SQL Server you get the following error:<\/p>\n
This occurs basically when Ad Hoc Distributed Queries<\/strong> is disabled.<\/p>\n So how to enable this:<\/strong><\/p>\n Simple by just changing the configuration of SQL Server using sp_configure<\/strong> Following are the steps to enable Ad Hoc Distributed Queries on SQL Server:<\/strong><\/p>\n Open SQL Server Management Studio (SSMS)<\/p>\n Create a new query on master database This enables sp_configure to show advanced options<\/p>\n Now run sp_configure<\/p>\n As shown in the screenshot below you can see ‘Ad Hoc Distributed Queries’ having config_value of 0<\/p>\n
\nSQL 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’, see “Surface Area Configuration” in SQL Server Books Online. <\/font><\/p>\n
\nMore about using sp_configure can be found here<\/a><\/p>\n
\nRun the following query:
\n[sql]
\nsp_configure ‘show advanced options’,1
\nreconfigure
\n[\/sql]<\/p>\n