我嘗試訪問MSMS中的Excel文件。搜索到互聯網後,我無法正常工作。如何找出可用於SQL Server 2008的哪個ole提供程序?
這裏是我做過什麼:
我的環境:
Windows 7(64bit) SP 1,
Microsoft SQL Server 2008 (SP3) - 10.0.5500.0 (X64)
Office 2010 Pro Plus with Access installed(32 bit)
嘗試更改配置爲OLE,如:
exec sp_configure 'Advanced', 1 RECONFIGURE exec sp_configure 'Ad Hoc Distributed Queries', 1 RECONFIGURE EXEC 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
運行查詢:
SELECT * FROM OPENROWSET('MICROSOFT.ACE.OLEDB.12.0','Text;Database=C:\Temp\;','SELECT * FROM [test.csv]')
或
SELECT * FROM OPENROWSET('MICROSOFT.JET.OLEDB.4.0','Text;Database=C:\Temp\;','SELECT * FROM [test.csv]')
對於這兩種情況,我得到了這樣的錯誤消息:
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.
或
Msg 7308, Level 16, State 1, Line 1
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.
然後我檢查SQL服務器上的鏈接服務器,並有默認由運行系統sp提供10個供應商:
EXEC master.dbo.sp_MSset_oledb_prop
SQLOLEDB
MSOLAP
SQLNCLI11
ADsDSOObject
SQLNCLI
SQLNCLI10
Search.CollatorDSO
MSDASQL
MSDAOSP
MSIDXS
如何解決此問題? 如何知道MICROSOFT.ACE.OLEDB.12.0
或MICROSOFT.JET.OLEDB.4.0
是否適用於SQL Server?
OLE DB 4.0與64位不兼容。你使用的是什麼版本的AccessDatabaseEngine? – 2013-03-15 14:48:21
我使用了Office 2010 32位。然後我更改爲Office 2010 64位,它看起來像使用excel xls文件:select * from OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 8.0; Database = C:\ Temp \ Test.xls;', 'SELECT * FROM [Location1 $]')。但它不適用於像excel xlsx文件:select * from OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 9.0; Database = C:\ Temp \ Test.xlsx;', 'SELECT * FROM [Location1 $]')。如何使它與xsls文件一起使用?這種情況下OpenRowSet的語法是什麼? – KentZhou 2013-03-20 13:48:43