solving sql server problems for millions of dbas and developers since 2006



SQL Server DBA Tips SQL Server Developer Tips SQL Server Business Intelligence Tips SQL Server Career Tips SQL Server Whitepapers SQL Server Tools SQL Server Webcasts SQL Server Questions and Answers SQL Server Questions and Answers













select of data from excel into sql server

Asked 2/8/2012 6:12:31 PM by amir younas

dear concerned,

i am using the followng configuration 

os=windows 2003 server

sql server=2005

ms excel=2007

i select data from excel using the following configuration and query.

EXEC sp_configure 'show advanced options', 1;

GO

RECONFIGURE;

GO

EXEC sp_configure 'Ad Hoc Distributed Queries', 1;

GO

RECONFIGURE;

GO

 

SELECT * FROM

OPENROWSET

(

'MICROSOFT.ACE.OLEDB.12.0',

'EXCEL 12.0;DATABASE=D:example.XLSX;',

'SELECT * FROM [SHEET1$]'

)

it is working fine.

but when i used the same configuration and query for the following specificatin

windows 2008 server

sql server 2008r2

excel 2007

it returns the error msg:

Msg 7302, Level 16, State 1, Line 1

Cannot create an instance of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)".

i install AccessDatabaseEngine driver(driver for excel) but it is still not working and returning the same error.

please please help me...



Answered 2/9/2012 1:13:47 PM by Jeremy Kadlec (0) vote answer is useful vote answer is NOT useful

Amir,

I am not sure if this is the issue or not, but it looks like you are missing a slash (i.e. '\') in this line of code:

'EXCEL 12.0;DATABASE=D:example.XLSX;',

 

 I also do not remember Excel 2007 that well, but have you tried this type of syntax:

'Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\testing.xls;',

HTH.

Thank you,
Jeremy Kadlec


Answered 2/9/2012 2:20:08 PM by Ray Barley (0) vote answer is useful vote answer is NOT useful

Is your Windows 2008 and SQL Server 2008 R2 running 64 bit?  

There are 64 bit drivers available; see http://www.microsoft.com/download/en/details.aspx?id=13255 to download. 


Answered 2/9/2012 2:32:08 PM by Jeremy Kadlec (0) vote answer is useful vote answer is NOT useful

Ray,

Great point! It could be a driver compatibility issue as well.

Thank you,
Jeremy Kadlec

 


Answered 2/9/2012 3:33:32 PM by amir younas (0) vote answer is useful vote answer is NOT useful

yes i am using windows 2008 and sql server 2008 R2 64 bit. but i have office 2007 32 bit. and when i try to install 64 bit driver it dose not allow me to install.


Answered 2/9/2012 3:35:08 PM by amir younas (0) vote answer is useful vote answer is NOT useful

Jeremy,

i try to it using '\' but still give the same error.


Answered 2/9/2012 4:11:05 PM by Jeremy Kadlec (0) vote answer is useful vote answer is NOT useful

Amir,

What error do you get when you try to install the 32 bit driver?  Or do you not have permissions to install software on the machine?

Thank you,
Jeremy Kadlec


Answered 2/9/2012 4:45:18 PM by amir younas (0) vote answer is useful vote answer is NOT useful

i did not get any error installing 32 bit driver it install successfully. but with 32 bit i think it does not work. when i im trying to install 64 bit driver i get error:

you cannot install the 64-bit bersion of microsoft access database enging 2010 because you currently have 32-bit ofice product installed. 

i want to using 32 bit excel with the same query and pull the record.

i tried the same code and setting mention in my question on 32 bit sql server and 32 bit office i was working fine. i im trying to use it with 64 bit of sql server and 32 bit of office. is there any way ????

 

thanks,

Amir.


Answered 2/9/2012 5:06:10 PM by Jeremy Kadlec (0) vote answer is useful vote answer is NOT useful

Amir,

I do not have time right now to test a scenario with SQL Server 64 bit and Office 32 bit, but I have a sneaking su***ion it does not work.

Let me see if I can test this in the near term.

Thank you,
Jeremy Kadlec


Answered 2/9/2012 6:30:32 PM by amir younas (0) vote answer is useful vote answer is NOT useful

Jeremy,

Thanks for your kind response.

amir,


Answered 5/15/2012 3:25:15 AM by Reiner Wellmann (0) vote answer is useful vote answer is NOT useful

I've too struggled a LOT with this issue and here's the answer to this.

In order to access Excel/Access files from SQL Server X64 here's what's important. Before even trying there can't be anything Office x86 related installed on the Box. If it is please uninstall.

Then install this: http://www.microsoft.com/en-us/download/details.aspx?id=13255

Then follow the directions here : http://www.excel-sql-server.com/excel-import-to-sql-server-using-distributed-queries.htm

Now you can use either :

SELECT * FROM OPENROWSET

(

       'Microsoft.ACE.OLEDB.12.0'

      ,'Excel 12.0;Database=D:\TEMP\Excel_File.xlsx'

      ,[Sheet1$]

)

OR use

SELECT * FROM OPENDATASOURCE

(

 'Microsoft.ACE.OLEDB.12.0'

,'Data Source=\\Server\Share\Access_DB.mdb'

)...[Table_Name]

Now it works. Should you really need Office installed, try it and see what's happening. I haven't dared yet. Post back with your results.



Post an Answer

Keep it clean and stay on the subject or we may delete your comment.
Your email address is not published. Required fields are marked with an asterisk (*)

*Name   *Email   Notify for updates
Comments
*Enter Code refresh code


 
Sponsor Information
"Amazing, Amazing, Amazing! SQL doctor is truly one of the most powerful tools I have seen."

It takes just 5 minutes to connect your SQL Databases to source control. Got 5 minutes? Get started now.

What grade do you think your SQL Servers get? Find out with Edgewood's SQL Server Health Check starting at $995.

Free Trial: Get Proactive Insight with Spotlight® for SQL Server Enterprise.

Solving SQL Server problems for millions of DBAs and Devs since 2006. Join now.

The SQL Server Security THREAT - It’s Closer Than You Think


Copyright (c) 2006-2012 Edgewood Solutions, LLC All rights reserved
privacy | disclaimer | copyright | advertise | about
authors | contribute | feedback | giveaways | user groups
Some names and products listed are the registered trademarks of their respective owners.


Edgewood Solutions LLC | MSSharePointTips.com | MSSQLTips.com