x

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 ??

more ▼

asked Feb 28, 2010 at 10:24 AM in Default

gil eichenbaum gravatar image

gil eichenbaum
1 1 1 1

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

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

more ▼

answered Mar 03, 2010 at 04:23 AM

Madhivanan gravatar image

Madhivanan
1.1k 1 3 6

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x1841
x373
x115
x32
x15

asked: Feb 28, 2010 at 10:24 AM

Seen: 3571 times

Last Updated: Feb 28, 2010 at 10:24 AM