尝试将Excel文件导入SQL时查询出错

时间:2013-05-17 09:09:17

标签: sql excel stored-procedures

我从http://support.microsoft.com/kb/321686获得了此代码,我做了示例,我正在尝试创建一个存储过程:

use [Libatel]
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Import1]

AS
BEGIN
SELECT * INTO CardsImported FROM OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0',
'Data Source=C:\Barcode.xls;Extended Properties=Excel 8.0')...[Sheet1$]

END
GO

但是我无法创建它,我收到了这个错误:

"Msg 7308, Level 16, State 1, Procedure Import1, Line 6>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."

1 个答案:

答案 0 :(得分:1)

  找到了方法!好吧,我有一台64位PC,我卸载了我的32位办公室随PC一起提供,我得到了64位版本,我从http://www.microsoft.com/en-us/download/details.aspx?id=23734下载了“AccessDatabaseEngine_x64.exe”,这几乎是