Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import data to SQL Server table from Excel

I am trying to import data from excel file to SQL Server table. I am getting this error "External table is not in the expected format (Microsoft Office Access Database Engine)" I am using Microsoft SQL Server 2012 and Excel 2007. I tried Microsoft SQL Server Import and Export wizard. Then I chose Microsoft Excel as Data source, chose the file name and chose the version of excel. Then i got the above error message.

like image 393
prabs Avatar asked Apr 23 '15 20:04

prabs


People also ask

Can Excel update a SQL table?

The data in SQL Server tables can be directly updated from Excel. Users are authenticated using their Windows Login and can only work with the Excel documents for which they are authorized. Data is automatically validated when users enter their figures through SQL Spreads.

Can we import CSV in SQL Server?

For content related to the Import and Export Wizard, see SQL Server Import and Export Wizard. Import Flat File Wizard is a simple way to copy data from a flat file (. csv, . txt) to a new table in your database.


2 Answers

Found out that it was to do with the excel file. Before opening the excel file i got this error message "The file you are trying to open .xls is in a different format than specified by the file extension. Verify that file is not corrupted and is from a trusted source before opening the file. " Opened it and copied its contents and created a new excel file from it. Then I used this file to import in the wizard. I specified Microsoft Excel as source with file name and Microsoft excel 2007 as version. For the destination I chose SQL Server Native client 11.0, Server name and database. I chose edit mappings to map the fields between excel sheet and target table. After running the wizard it transferred the data to the target table in sql server.

like image 56
prabs Avatar answered Oct 10 '22 13:10

prabs


Save it with a different name as the latest xlsx version. Nevermind if you think you changed nothing, it actually did. Then try to import the new file.

like image 44
Dgloria Avatar answered Oct 10 '22 14:10

Dgloria