question

gil eichenbaum avatar image
gil eichenbaum asked

How to import data from Excel file on local machine to Sql Server using Query

Hi !

I am trying to import excel table into my sql database.

My excel file is on my local machine and I tried this code :

SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=Q:\Documents and Settings\Administrator\My Documents\myfile.xls', 'SELECT * FROM [QPrintPolicyRenew$]')

I keep getting this error :

Cannot get the column information from OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)".

Can anyone help ??

sql-server-2008queryexcelbulk-insertdata-import
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
Madhivanan avatar image
Madhivanan answered

The first line of the EXCEL file should have column informations Refer this for more informations http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=49926

10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.