-
Excelent article. Thank you!
-
Thanks for this page. I have been floundering for over a week with a very similar task. Your blog page brought everything together for me, as well as provided a totally new path for investigation. I have saved this to my favs because I am sure I will be referring to it in the future.
thx again
-
-
Thanks for posting but none of these methods did not solve my problem. I am working wtih Win 7, SQL Server 2008 x64, Excel 2007. I am getting this error:
OLE DB provider ‘Microsoft.ACE.OLEDB.12.0′ cannot be used for distributed queries because the provider is configured to run in single-threaded apartment mode. Yes, I tried this too:
sp_configure
GO
sp_configure ‘show advanced options’, 1
GO
reconfigure
GO
sp_configure ‘Ad Hoc Distributed Queries’, 1
GO
reconfigure
GOIt did not work. I check, I have the right driver. No matter what I do I get the error. Any help would be appreciated. Thanks!
-
great article..!
really helpful..! -
have you tested mixing text and numbers to see if they finally get it working?
previously you can not do that without getting velues replaced by nulls.
regards.
-
How do you solve this?
The problem I have on a particular column is that there are both text and numbers. I tried forcing Excel to save the whole column as text, but the numbers are still imported as NULL.
Ex: VOIP imports fine, 1024 doesnt. The whole column was marked and saved as TEXT in Excel.
I’m using a Excel 2003 file.
-
So you are using Provider=Microsoft.Jet.OLEDB.4.0?
-
-
-
Great Comments !!! That is all.
-
Very helpful great article.
-
hi,
I am getting Following error after all Configuration:
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.Please do the need full…..
Regards
Ajit Singh -
Version Info For Above is:
Microsoft SQL Server Management Studio 10.50.1600.1
Microsoft Data Access Components (MDAC) 3.85.1132 -
hi there,
I am trying to update the SQL(sql server 2008) table using Excel 2010. I am receiving the follwoign error.
OLE DB provider “Microsoft.ACE.OLEDB.12.0″ for linked server “(null)” returned message “Could not find installable ISAM.”.
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider “Microsoft.ACE.OLEDB.12.0″ for linked server “(null)”.
.
I have installed the Microsoft.ACE.OLEDB.12.0.I have tried all the bits but it gives me differnt error each time.
Regards
-
Hi i get the same message like Nitesha and i already setup ACE driver 64bit.
SELECT * –INTO #productlist
FROM OPENROWSET(‘Microsoft.ACE.OLEDB.12.0′,
‘Excel 12.0 Xml;HDR=YES;Database=C:\temp\test.xlsx’,
‘SELECT * FROM [test$]‘);OLE DB provider “Microsoft.ACE.OLEDB.12.0″ for linked server “(null)” returned message “Unspecified error”.
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider “Microsoft.ACE.OLEDB.12.0″ for linked server “(null)”.Best Regards,
Jaroslaw Kucharski -
Under Windows 2008 64 bit with the Microsoft Access Database Engine 2010 64bit installed, running the query as an administrator (run as) solved this error for me :
Cannot initialize the data source object of OLE DB provider “Microsoft.ACE.OLEDB.12.0″ for linked server “(null)”.
-
hi Valentino ,
this was a very useful article. but , I have still the same errors.I have put the queries none worked.
sp_configure ‘show advanced options’, 1;
GO
RECONFIGURE;
GOsp_configure ‘Ad Hoc Distributed Queries’, 1;
GO
RECONFIGURE;
GOSELECT * –INTO dbo.BulkLead
FROM OPENROWSET(‘Microsoft.ACE.OLEDB.12.0′,
‘Excel 12.0;HDR=YES;Database=C:\Users\CRM_Admin.CONTOSO\Desktop\crownap\LeadTemplate.xls’,
‘SELECT * FROM [Sheet1$]‘);I am trying to run this in windows2008 64-bit, SQL 2008 64-bit, installed AccessDatabaseEngine _x64.exe, AccessRuntime 2010, but there is no MS Office installed.
and the Error I am getting are:
Msg 7303, Level 16, State 1, Line 2
Cannot initialize the data source object of OLE DB provider “Microsoft.ACE.OLEDB.12.0″ for linked server “(null)”. -
thanks valentino.
I was not able to open the file itself in the server as there was no Office installed. So the question of file open or closed does not exist.
Then , i read in other forum. try to export from excel to SQL using SSIS. first that also gave the same error.
Then,I could at least get the connection succeeded using ““Microsoft.ACE.OLEDB.12.0″.But, again when i tried the above procedure , i get the same error.
Now, I have also installed the Office 64-bit , still the issue persists.Please help me.
-
Thanks for all your info…
I tried do all this, but with no good effect.
I only get SUCCESS when I disable the UAC.
This solves my problems…
Hope this helps to all!!!
-
Can you use Ace 12.0 OleDB provider on an Excel 2010 file? Or you need Ace 14.0 and this one will work on 2007-2010 files? I am having a problem with 255 column limitations with ACE 12.0, do you have any work around for it?
Thanks,
Mihail-
Hi Valentino:
ANY chance that you can answer my question regarding ACE providers column limitation to 255?? I REALLY appreciate a suggestion here since I am using it and have this problem.-
Hi Valentino:
Any chance I get some help(advice) from you regarding the 255 column limitation?
Thanks,
Mihail
-
-
-
my story:
windows 7(x64),mssql2008(x64),office 2007(32bit)..can’t install the AccessDatabaseEngine_X64–because of office 32bit.
install AccessDatabaseEngine — mssql2008 can’t load it?…
Cannot initialize the data source object of OLE DB provider “Microsoft.ACE.OLEDB.12.0″ for linked server “(null)”. msg:7302too bad…..
-
I want to export select query data to excel but error is giving in sql server 2008
Msg 7403, Level 16, State 1, Line 3
The OLE DB provider “Microsoft.Jet.OLEDB.4.0″ has not been registered.Please help me
-
I have configured as per above informaiton still i am getting below error
Msg 7357, Level 16, State 2, Line 1
Cannot process the object “SELECT * FROM [rep_268662$]“. The OLE DB provider “Microsoft.ACE.OLEDB.12.0″ for linked server “(null)” indicates that either the object has no columns or the current user does not have permissions on that object.Please help..!!
-
Anyone plz help me out of this error.. i have spent amost a day on this..!!
-
I fought with this error too and it turned out (ouch) that the actual Excel spreadsheet was named Sheet1 internally but I was referring to it by the name of the Excel file e.g. my_spreadsheet_data. The sheet name can be anything but the query has to use the right name.
-
-
Have you disabled the UAC?
-
Great article. Very informative. I’ve encountered an issue where all numbers imported from Excel are truncated at 4 decimal places. I’m using TypeGuessRows=0 and ImportMixedTypes=Majority Type in the registry for the ACE 14.0 OLEDB provider but it still truncates at 4. Any help would be appreciated.
-
if you find a solution please post it here, since I have been looking for it for more than 5 years.
the only workaround is to use excel Activex to load the file then read cell by cell to export it to any other format.(CSV,DataSet, etc.)
good luck.
-
5 years? Dude – get a life! You must have meant days.
-
-
-
It is very useful information to use.
How ever I am this error “Msg 7302, Level 16, State 1, Line 1, Cannot create an instance of OLE DB provider “Microsoft.Jet.OLEDB.4.0″ for linked server “(null)”.”
Surprisingly I am able to run the same query on my Sandbox and it works like charm. But when I copy this to my production box, it gives me the above error.
I have checked and see my Drive in ODBC Driver.
The onther thing, I did enable the ‘Ad hock distributed queries’ but did not restart my SQL Box. Do I have to
-
AFAICT you do not need to restart your SQL Server instance. YMMV
-
-
My .xlsx file is closed but i am still getting this error
Cannot initialize the data source object of OLE DB provider “Microsoft.ACE.OLEDB.12.0″ for linked server “(null)”.
What can be the reason then. Also can i pass local file path to openrowset query. If yes then what is the syntax for that. Please help.
-
Several additional observations:
(Environment is Win7 Ultimate, SQL Server 2008 R2 Express, Excel 2010)1) Leaving Excel running even if the spreadsheet is closed appeared to cause problems. Maybe it somehow monopolizes the drivers. Not sure. Shutdown Excel, and my imports worked.
2) Naming the worksheets other than Sheet1 is OK, but update the query accordingly.
3) Columns with mixed numbers and letters seem to cause issues, but I overcame this by forcing the column format to Text (maybe this was already mentioned). I also forced date columns to date format.
4) Use column headers!
5) The TryGuessRows thing matters as everyone can attest! There are 2 instances of this setting in my registry. It does beg the question why this Microsoft (un)-helpfulness is not exposed as a configurable application property rather than forcing REGEDIT mining.
6) Putting the following script snippet at the top of each query will overcome forgetting all these tweaks next time you come back to this topic:USE [master]
GO
exec sp_configure ‘show advanced options’, 1
GORECONFIGURE WITH OverRide
GOexec sp_configure ‘Ad Hoc Distributed Queries’, 1
RECONFIGURE
exec sp_configure ‘xp_cmdshell’, 1
RECONFIGURE
GOEXEC master.dbo.sp_MSset_oledb_prop N’Microsoft.ACE.OLEDB.12.0′, N’AllowInProcess’, 1
EXEC master.dbo.sp_MSset_oledb_prop N’Microsoft.ACE.OLEDB.12.0′, N’DynamicParameters’, 1
GO7) I would really appreciate it if somebody could comment back here as to a simple means to generate CSV files from Excel that surround the values with dquotes. That would have solved a bunch of issues for me. That is way old-school I know but it unambiguously deals with mixed type columns. Maybe it is a mysterious CSV Save-As setting I did not see.
-
Oh, and the working directory problem will bite you as mentioned. It is perhaps a security nightmare, but anyone trying to use these query things must have rights to the place where the SQL Server Engine user account puts its temp files. I use an explicit user account MSSQLEngine with limited rights, as MSS recommends, so I have granted Everyone rights to the temp folder of the user MSSQLEngine, which is as I recall
C:\Users\MSSQLEngine\AppData\Local\Temp
With a dedicated user that runs the MSS engine, at least, you don’t have to expose a directory under Windows\System etc. I think that would be wise.
-
-
I am trying to tranfer data from excel to SQL server 2008 R2 table using the below command suggested in your article:
INSERT INTO dbo.Employee
SELECT * –INTO #productlist
FROM OPENROWSET(‘Microsoft.Jet.OLEDB.4.0′,
‘Excel 8.0;HDR=YES;Database=\\compname\d$\Emp\Appl.xlsx’,
‘select * from [Sheet1$]‘);I get the below error. I tried the sp_configure and also downloaded the exe from
http://www.microsoft.com/en-us/download/details.aspx?id=13255
but still getting below error. Please suggest.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.
-
believe me the best way to load excel files is using its ActiveX control follow this link
http://csharp.net-informations.com/excel/csharp-open-excel.htm
regards.
-
Hi pepepaco:
2 questions for you:
1. Can you return a DataTable for each of the worksheets using ActiveX, similar with what the OLEDB reader does?
2. Can you surpass the 256 column limits with ActiveX that OLEDB reader can’t?Thanks!
-
Excel 2007 or later will be the intended target. At this time I am using the MS OLEDB reader that’s why I asked if you can retrieve all your worksheets via the ActiveX. Also, when you get you data via the Activex can you get them into a table for each worksheet, so that table would become a data source for a grid basically having the same columns as the worksheets? What do you know about data format, are they preserved? If you have or will work to something similar my asking, please let me/us know and post the code or a link to it.
Thanks.-
besides the link i have already provided here is another http://www.dotnetperls.com/excel
or just google for Microsoft.Office.Interop.Excelregards
-










55 comments
Comments feed for this article
Trackback link: http://blog.hoegaerden.be/2010/03/29/retrieving-data-from-excel/trackback/