解決SQL Server 2008 64位系統無法匯入Access/Excel的問題 2012/08/01

來源:互聯網
上載者:User

標籤:

作業系統Windows Server 2008 X64,資料庫SQL Server 2008 X64,Office 2007(好像只有32位),在預存程序執行OpenDatasource匯入Access資料的時候遇到問題了,Oledb 4.0已經不被支援,以下是遇到的若干錯誤提示:

 

 

因為 OLE DB 提供者 ‘Microsoft.Jet.OLEDB.4.0‘ 配置為在單一執行緒 Apartment模式下運行,所以該提供者無法用於分散式查詢。無法建立連結的伺服器 "(null)" 的 OLE DB 提供者 "Microsoft.Ace.OLEDB.12.0" 的執行個體。因為 OLE DB 提供者 ‘Microsoft.Ace.OLEDB.12.0‘ 配置為在單一執行緒 Apartment模式下運行,所以該提供者無法用於分散式查詢 。

 

解決方案是安裝Office 2010 64位版, 網上有很多下載,然後下載Microsoft Access Database Engine 2010 的X64版本,網上也有下載,兩者缺一不可。

 

然後改一下OpenDatasource參數,將 Microsoft.Jet.OLEDB.4.0 改為 Microsoft.ACE.OLEDB.12.0,大功告成。

 

貼上預存程序部分代碼:

 

 

--開啟匯入功能
exec sp_configure ‘show advanced options‘,1
reconfigure
exec sp_configure ‘Ad Hoc Distributed Queries‘,1
reconfigure
--允許在進程中使用ACE.OLEDB.12
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

--匯入暫存資料表 
exec (‘insert into jihua(id,[批次號],Right(‘‘‘+ @filepath +‘‘‘,charindex(‘‘\‘‘,REVERSE(‘‘‘+ @filepath +‘‘‘))-1),getdate() FROM OPENDATASOURCE (‘‘Microsoft.ACE.OLEDB.12.0‘‘, ‘‘Data Source=‘[email protected]+‘;User ID=Admin;Password=‘‘ )...計劃匯總表‘)

--注意這裡,要先關閉外圍的設定,然後再關閉進階選項
exec sp_configure‘Ad Hoc Distributed Queries‘,0
reconfigure
exec sp_configure‘show advanced options‘,0
reconfigure
--關閉ACE.OLEDB.12的選項
EXEC master.dbo.sp_MSset_oledb_prop N‘Microsoft.ACE.OLEDB.12.0‘, N‘AllowInProcess‘, 0
EXEC master.dbo.sp_MSset_oledb_prop N‘Microsoft.ACE.OLEDB.12.0‘, N‘DynamicParameters‘, 0

解決SQL Server 2008 64位系統無法匯入Access/Excel的問題 2012/08/01

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.