January 12, 2011 at 5:41 pm
Hello everyone,
I have an Excel file with just one field and it contains numbers. I want to read the Excel file into a table in SQL Server. I have tried to use
select * into tablename
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=D:\testing.xls;HDR=YES', 'SELECT * FROM [Sheet1$]')
However I am unsuccessful because I get the following error
Msg 7308, Level 16, State 1, Line 2
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.
Can you please help me out. I dont want to use SSIS. All I want is T-SQL.
Thank you all in advance.
January 13, 2011 at 3:44 am
January 13, 2011 at 3:50 am
Junglee_George (1/13/2011)
Try this useful link
:ermm:
Did you read the original question? The link you provided just explains how to import data from excel using the OPENROWSET command. The OP has already done that, there is a problem with the provider.
@divya-2: check if distributed queries are enabled in your db:
EXEC sp_configure 'ad hoc distributed queries'
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
January 13, 2011 at 7:47 am
Just curious, have you tried using the Import Data Wizard? I'm not sure it will meet your needs or not, but you can frequently get a lot more error information out of that than with OPENROWSET. It might help, just to try.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
January 14, 2011 at 11:38 am
Here are the steps to allow distributed ad hoc queries:
sp_configure 'show advanced options', 1
reconfigure
sp_configure 'Ad Hoc Distributed Queries', 1
reconfigure with override
This should handle the problem.
Todd Fifield
January 15, 2011 at 2:41 pm
Hi all,
sp_configure 'show advanced options', 1
reconfigure
sp_configure 'Ad Hoc Distributed Queries', 1
reconfigure with override
With this script I was able to read from the Excel file. Thank you all for helping me..
January 15, 2011 at 7:21 pm
Divya,
Glad to be of help.
Todd Fifield
August 7, 2013 at 4:57 pm
Hi all,
I've checked my configuration with sp_configure and 'Ad Hoc Distributed Queries' value is 1.
And when I exec my script to import Excel data into SQL table it returns this:
Msg 7308, Level 16, State 1, Line 2
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.
The syntax is OK and the Configuration too. So, Why I'm getting that error message?
Thanks in advance.
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply