Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Problem using T-SQL for Excel Import

$
0
0

In SSMS, working with SQL Server 2008 R2, I can choose Database, Tasks, Import which launches the SQL Server Import and Export Wizard.  I can use the Wizard to create and save a SSIS package to import an Excel 2003 or 2007 workbook.  
The connection string for Excel in the SSIS package is:
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=F:\PDM - Planning DataMart\Excel\MLNov13_BRR.xlsx;Extended Properties="EXCEL 12.0 XML;HDR=YES";
The problem is that the name of the Excel file will change with each run, so I’d like to use T-SQL instead of the SSIS package.
In SSMS, when I run:
SELECT * INTO XLImport FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'EXCEL 12.0 XML;Database=F:\PDM - Planning DataMart\Excel\MLNov13_BRR.xlsx', 'SELECT * FROM [Bottom Up Growth$]')
I get error:
Msg 7403, Level 16, State 1, Line 2
The OLE DB provider "Microsoft.ACE.OLEDB.12.0" has not been registered.
I’ve also tried converting the XLSX file to XLS and running:
SELECT * INTO XLImport FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'EXCEL 5.0 XML;Database=F:\PDM - Planning DataMart\Excel\MLNov13_BRR_2003.xls', 'SELECT * FROM [Bottom Up Growth$]')
Then I get 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.
It seems to be a configuration problem in SSMS.  Suggestions are appreciated.


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>