[SQL Server] import Excel Data to SQL Server

Source: Internet
Author: User
Tags sql server query
Run the following statement to query the Excel content:
Select * From OpenDataSource ('Microsoft. Jet. oledb.4.0 ', 'Data source = c: \ book1.xls; extended properties = Excel 8.0')... [t_table $]
C: \ book1.xls is the path of the Excel file to be imported, and t_table $ is the name of the Excel table. (Do not miss the $ symbol), Excel 8.0 this is the Excel version number, the Office97-2000 version number is 8.0

For example, you can write the imported data as follows: in the SQL Server Query analyzer, Type
Insert into [t_table] ([u_name])
Select * From OpenDataSource ('Microsoft. Jet. oledb.4.0 ', 'Data source = c: \ book1.xls; extended properties = Excel 8.0')... [t_table $]

Ms provides the following methods:
Select * into xlimport3 from OpenDataSource ('Microsoft. Jet. oledb.4.0 ',
'Data source = c: \ test \ xltest.xls; extended properties = Excel 8.0 ')... [MERs $]

Select * into xlimport4 from OpenRowSet ('Microsoft. Jet. oledb.4.0 ',
'Excel 8.0; database = c: \ test \ xltest.xls ', [MERs $])

Select * into xlimport5 from OpenRowSet ('Microsoft. Jet. oledb.4.0 ',
'Excel 8.0; database = c: \ test \ xltest.xls ', 'select * from [MERs $]')

For details, see:
Http://support.microsoft.com/default.aspx? SCID = KB; ZH-CN; 321686

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.