Access Excel---Select from excel in SQL Server

Source: Internet
Author: User
Tags sql server books

This article describes a method for querying Excel through SQL statements in Mssms.

Access to Excel is done primarily through the ACE data source provided by office, using OpenDataSource for access to Excel. That is, execute the following command in Mssms:

SELECT * from OpenDataSource (' microsoft.ace.oledb.12.0 ', ' data source= ' absolute path to Excel file "; Extended properties=excel 12.0 ') ... sheetname$--which ... and $ cannot be omitted

  If the statement appears "SQL Server blocked access to component ' Ad Hoc distributed Queries ' STATEMENT ' Openrowset/opendatasource ', Because this component has been shut down as part of this server's security configuration. System administrators can enable ' Ad Hoc distributed Queries ' by using sp_configure. For more information about enabling ' Ad Hoc distributed Queries ', see "surface area Configurator" in SQL Server Books Online. "You can execute EXEC sp_configure ' show advanced options ', 1 reconfigure and exec sp_configure ' Ad Hoc distributed Queries before executing the statement ', 1 reconfigure, the previous sentence is open show advanced settings, and the latter is open ' Ad Hoc distributed Queries '. After executing these two articles, you will have no problem executing the statement that accesses Excel. If you execute these two settings statements, finally be sure to re-execute exec sp_configure ' Ad Hoc distributed Queries ', 0 reconfigure and exec sp_configure ' show advanced Options ', 0 reconfigure to turn these two settings off, because this setting is extremely unsafe for the database if set to open.

Access Excel---Select from excel in SQL Server

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.