Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OLE DB provider 'Microsoft.Jet.OLEDB.4.0' cannot be used for distributed queries

Tags:

I want to import data from Excel to SQL Server using queries, not by using a wizard. I tried this query:

Select * INTO g FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 12.0;Database=D:\new.xlsx;HDR=YES', 'SELECT * FROM [newSheet$]'); 

But, I am getting this error:

Msg 7308, Level 16, State 1, Line 1
OLE DB provider 'Microsoft.Jet.OLEDB.4.0' cannot be used for distributed queries because the provider is configured to run in single-threaded apartment mode.

So I searched on Google, and I got answers like:

sp_configure 'show advanced options', 1; GO RECONFIGURE; GO sp_configure 'Ad Hoc Distributed Queries', 1; GO RECONFIGURE; GO 

Even after reconfiguring it is showing me the same error...

like image 415
Pரதீப் Avatar asked Feb 26 '14 05:02

Pரதீப்


1 Answers

According to this thread,:

Microsoft.Jet.OLEDB.4.0 is not supported for 64-bit OS

Assuming you are running SQL Server 64-bit, you likely need the 64-bit Microsoft Access Database Engine 2010 Redistributable.

And be aware that there is a minor wrinkle when trying to install the software if the other version is already installed. In this case install the second version from the command line using the /passive switch. According to this thread:

Launching the install of a Microsoft ACE OLEDB Provider on a machine with an Office install other than the current one (e.g. 32 on 64) will cause the install to fail. To have it run properly you need to launch it from a command line with the “/passive” argument specified.

That is talking about an existing Office install but the same applies to coexisting database engine installations.

EDIT: Also make sure to use "Microsoft.ACE.OLEDB.12.0" not "Microsoft.Jet.OLEDB.4.0" for the provider string. (Props to @Rumi)

like image 194
agentnega Avatar answered Sep 24 '22 03:09

agentnega