Sqlserver reads data in Excel

Source: Internet
Author: User

1. sqlserver reads data from Excel

Select *

From OpenDataSource ('Microsoft. Jet. oledb.4.0 ',

'Data source = "C:/book1.xls"; user id = admin; Password =; extended properties = Excel 5.0 ')... [sheet1 $]

2. sqlserver insert data in Excel

2.1Insert an existing table

Insert into T_1 (A, B)

Select a, B

From OpenDataSource ('Microsoft. Jet. oledb.4.0 ',

'Data source = "C:/book1.xls"; user id = admin; Password =; extended properties = Excel 5.0 ')... [sheet1 $] As derivedtbl_1


2.2 Insert a new table

 

Select a, B

Into T_2

From OpenDataSource ('Microsoft. Jet. oledb.4.0 ',

'Data source = "C:/book1.xls"; user id = admin; Password =; extended properties = Excel 5.0 ')... [sheet1 $] As derivedtbl_1

FAQs:

(1) Microsoft. Jet. oledb.4.0 is not registered on the local computer.Program

Problems and Solutions:

1. Microsoft. Jet. oledb.4.0 should not be written as miscrosoft. Jet. oledb.4.0 ,;

2. Do not write data source as "Data sourse ",

3. Check whether the Office is installed

4.reinstall and register mdac28.exe. (generally, your installation directory contains or goes to Microsoft's official website)

5. this problem may also occur on a 64-bit platform. Solution: Generate, Configure Manager, and platform. Click the any CPU tab. Choose new from create platform to x86.
(2) Enable OpenRowSet and OpenDataSource support for sqlserver

And then restart sqlserver

For details, refer:

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.