SQL Server blocks the STATEMENT 'openrowset/OpenDatasour of the 'ad Hoc Distributed Queries 'component.

Source: Internet
Author: User
Tags sql server books

SQL Server blocks access to component \ 'ad Hoc Distributed Queries \'

An error occurred while querying the Excel file in SQL Server:
SELECT * from openrowset ('Microsoft. JET. OLEDB.4.0 ', 'excel 8.0; IMEX = 1; HDR = YES; DATABASE = D: \ a.xls', [sheet1 $])
Result prompt:
SQL Server blocks access to the STATEMENT 'openrowset/OpenDatasource 'of the 'ad Hoc Distributed Queries' component because this component has been disabled as part of the Server's security configuration. The system administrator can enable 'ad Hoc Distributed Queries 'by using sp_configure '. For more information about enabling 'ad Hoc Distributed querys', see "peripheral application configurator" in SQL Server books online ".
Query relevant information and find the solution:

Enable Ad Hoc Distributed Queries:
Exec sp_configure 'show advanced options', 1
Reconfigure
Exec sp_configure 'ad Hoc Distributed Queries ', 1
Reconfigure
After use, disable Ad Hoc Distributed Queries:
Exec sp_configure 'ad Hoc Distributed Queries ', 0
Reconfigure
Exec sp_configure 'show advanced options', 0
Reconfigure

SELECT *
From opendatasource (
'Sqlodb ',
'Data Source = ServerName; User ID = sa; Password = Sa'
). DataBaseName. dbo. Table

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.