Import Excel Data to the SQL Server database

Source: Internet
Author: User

1) the table to be imported already exists.
insert into T1 select * From OpenRowSet ('Microsoft. jet. oledb.4.0 ',
'excel 5.0; HDR = yes; database = c: \ test.xls', sheet1 $);
2) import data and generate tables.
select * into T1 from OpenRowSet ('Microsoft. jet. oledb.4.0 ',
'excel 5.0; HDR = yes; database = c: \ test.xls', sheet1 $);

3) import the specified columns in Excel to the specified columns in the database table.
Insert into T1 (A1, A2, A3) Select A1, A2, A3 from OpenRowSet'Microsoft. Jet. oledb.4.0 ','Excel5. 0; HDR = yes; database = c: \ test.xls ', sheet1 $ );

Note.
1) configure the peripheral application configurator.
Select "enable OpenRowSet and OpenDataSource support" from "function Peripheral application configurator.
2) Close the Excel table.
If the Excel table to be imported is in the open state during import, the following message is displayed:
"Unable to initialize the data source object for the ole db access interface "Microsoft. Jet. oledb.4.0" of the linked server "(null ."
3) When importing data, the first line of Excel is used as the header. If it is imported to an existing database table, the first line is ignored.

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.