SQL advanced application methods for using SQL to query Excel table data _mssql

Source: Internet
Author: User

Copy Code code as follows:

exec sp_configure ' show advanced options ', 1
Reconfigure
exec sp_configure ' Ad Hoc distributed Queries ', 1
Reconfigure

Copy Code code as follows:

SELECT * from OpenDataSource (' microsoft.jet.oledb.4.0 ',
' Data Source=e:\haierweb\myweb\doc\abc.xls; Extended properties=excel 8.0 ') ... sheet1$


The first line is the table header.
The remaining rows are treated as a data type and cannot be converted, if there is text, there is a number, one appears as many, and the rest is null

Employee Information F2
NULL Name
664754 sheets of three
664783 Dick

The Null place should be the employee number. The first two lines are the header of the table.

For this form, you should convert the number to the previous one ' (single quotation mark) to the text format. Fill in the same content quickly after selecting multiple cells, enter the characters, and then press Ctrl+enter to fill in the same characters in each cell that you select.

Workaround:
Copy Code code as follows:

SELECT * from OpenDataSource (' microsoft.jet.oledb.4.0 ',
' Data Source=e:\haierweb\myweb\doc\abc.xls; Extended properties= "Excel 8.0; hdr=yes;imex=1; "') ... sheet1$


Hdr=yes, is to say that the first column as the head of the table.
Imex=1, is to say the contents of the table mixed read.

Jet actually supports so many databases, and even HTML table is supported.

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.