dbTalk Databases Forums  

Need Help Importing Data from Excel to My SQL Database

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Need Help Importing Data from Excel to My SQL Database in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
alvinstraight38@hotmail.com
 
Posts: n/a

Default Need Help Importing Data from Excel to My SQL Database - 01-16-2008 , 12:13 PM






Hey guys,

I am trying to import data from an Excel spreadsheet into my SQL
database. I am running SQL 2005.

I following Microsoft's instructions for creating a linked server, and
it appeared to work. However when I run this query:

SELECT * INTO test FROM OPENQUERY(EFORMS,
'SELECT * FROM [Form Tracker Baseline$]')


I get the following error:

The OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server
"EFORMS" reported an error. The provider did not give any information
about the error.
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider
"Microsoft.Jet.OLEDB.4.0" for linked server "EFORMS".


Test is the table that will receive the imported data. Eforms is the
name of my linked server, and Form Tracker Baseline is the worksheet
name.

The error sounds like it can not locate my spreadsheet. Any ideas why
I am getting this message? Is there an easier way to do this import?

Thanks,

Reply With Quote
  #2  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: Need Help Importing Data from Excel to My SQL Database - 01-16-2008 , 04:30 PM






alvinstraight38 (AT) hotmail (DOT) com (alvinstraight38 (AT) hotmail (DOT) com) writes:
Quote:
I am trying to import data from an Excel spreadsheet into my SQL
database. I am running SQL 2005.

I following Microsoft's instructions for creating a linked server, and
it appeared to work. However when I run this query:

SELECT * INTO test FROM OPENQUERY(EFORMS,
'SELECT * FROM [Form Tracker Baseline$]')


I get the following error:

The OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server
"EFORMS" reported an error. The provider did not give any information
about the error.
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider
"Microsoft.Jet.OLEDB.4.0" for linked server "EFORMS".


Test is the table that will receive the imported data. Eforms is the
name of my linked server, and Form Tracker Baseline is the worksheet
name.

The error sounds like it can not locate my spreadsheet. Any ideas why
I am getting this message?
To me it sounds like SQL Server cannot find Excel at all. Do you have
SQL Server on the same machine as you have Excel?

Quote:
Is there an easier way to do this import?
If I had an Excel book that I wanted to import to SQL Server, I would
save it as a comma-separated file and then use BCP. Don't really know
whether that is easier, but it's the only way I know...


--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx


Reply With Quote
  #3  
Old   
aj
 
Posts: n/a

Default Re: Need Help Importing Data from Excel to My SQL Database - 01-17-2008 , 10:13 AM



Erland Sommarskog wrote:

Quote:
If I had an Excel book that I wanted to import to SQL Server, I would
save it as a comma-separated file and then use BCP. Don't really know
whether that is easier, but it's the only way I know...
SSIS (ala OLE DB). Works like a charm....

aj



Reply With Quote
  #4  
Old   
alvinstraight38@hotmail.com
 
Posts: n/a

Default Re: Need Help Importing Data from Excel to My SQL Database - 01-18-2008 , 10:43 AM



On Jan 17, 10:13*am, aj <ron... (AT) mcdonalds (DOT) com> wrote:
Quote:
Erland Sommarskog wrote:
If I had an Excel book that I wanted to import to SQL Server, I would
save it as a comma-separated file and then use BCP. Don't really know
whether that is easier, but it's the only way I know...

SSIS (ala OLE DB). *Works like a charm....

aj
Ahhh just my luck. I am on the free version of 2005 so it looks like
SSIS is not available.


Reply With Quote
  #5  
Old   
Jim Johannsen
 
Posts: n/a

Default Re: Need Help Importing Data from Excel to My SQL Database - 01-25-2008 , 07:51 PM



On Wed, 16 Jan 2008 10:13:10 -0800, alvinstraight38 (AT) hotmail (DOT) com wrote:

Quote:
Hey guys,

I am trying to import data from an Excel spreadsheet into my SQL
database. I am running SQL 2005.

I following Microsoft's instructions for creating a linked server, and
it appeared to work. However when I run this query:

SELECT * INTO test FROM OPENQUERY(EFORMS,
'SELECT * FROM [Form Tracker Baseline$]')


I get the following error:

The OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "EFORMS"
reported an error. The provider did not give any information about the
error.
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider
"Microsoft.Jet.OLEDB.4.0" for linked server "EFORMS".


Test is the table that will receive the imported data. Eforms is the
name of my linked server, and Form Tracker Baseline is the worksheet
name.

The error sounds like it can not locate my spreadsheet. Any ideas why I
am getting this message? Is there an easier way to do this import?

Thanks,
I haven't set up a worksheet as a linked sever but I do read from excel
all the time:

insert into foobar
select *
from openrowset
('Microsoft.Jet.oledb.4.0',
'excel 8.0;database=dir\filename.xls',
[sheet$])

The dollar sign is required for the sheet name.

Watch out for data types conversions and verify what is loaded. I've
been burned a couple of times with these problems. Usually traced to
excel not knowing data types. In these cases, create a csv file and use

insert into foobar
select *
from opendatasource
('Microsoft.Jet.oledb.4.0',
'Data Source=directory;
extended properties="text;hdr=yes;"')...filename#fileext

Make sure OpenDataSource and OpenRowSet are enabled.



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.