Import EXCEL Data to the SQL SERVER database.

Source: Internet
Author: User

Import EXCEL Data to the SQL SERVER database.

Method 1 ..

View the procedure

Right-click the database, select "task", and select "import data". The pop-up dialog box for "Fade in data" appears.



It is best to name the fields in Excel the same as those in the table to be imported. Assume that the final table is table. Assembled as follows:



Follow these steps to generate a new table (temporary table B ).

You can use the tools to export MSSQL table data to Insert statements: Generate insert into statements for all the queried data.


Finally, execute the insert into statement in Table A to put the data in excel into the database.


Method 2:

Direct import using statements

Insert into hr_staff (uuid, dept, staff_name, gender, nation, birthday, political, native_city, identy,
Position, pos_level, work_date, pos_begin, gradschool, professional, degree, education, remark)
Select * from OpenRowSet ('Microsoft. ACE. OLEDB.12.0 ', 'excel 8.0; HDR = Yes; IMEX = 1; Database = D: \ 13.xls', 'select * from [sheet1 $] ')


The excel Field should be consistent with the insert into field.




If you use this statement, you will encounter a lot of problems. We will follow the prompts to Solve the Problem step by step.

Question 1:

Ole db access interface 'Microsoft. jet. OLEDB.4.0 'is configured to run in single-threaded unit mode. Therefore, this access interface cannot be used for Distributed Query. solution:. the database that executes the preceding SQL statement must be a local database. If it is a remote database, the preceding error is reported. B. jet is not provided in 64 SQL Engine. oledb.4.0 driver. Solution: download an ACE. oledb.12.0 for X64 driver, and connect the connection string to Microsoft. jet. oledb.4.0 changed to Microsoft. ACE. OLEDB.12.0 problem 2: The ole db access interface "Microsoft. ace. OLEDB.12.0. Solution: -- enable the import function
Exec sp_configure 'show advanced options', 1
Reconfigure
Exec sp_configure 'ad Hoc Distributed Queries ', 1
Reconfigure
-- ACE. OLEDB.12 is allowed in the process.
EXEC master. dbo. sp_MSset_oledb_prop N 'Microsoft. ACE. OLEDB.12.0 ', n' allowinprocess', 1
-- Allow dynamic parameters
EXEC master. dbo. sp_MSset_oledb_prop N 'Microsoft. ACE. OLEDB.12.0 ', n' DynamicParameters', 1




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.