我想要执行简单的语句:OPENROWSET与Excel文件
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.
这是工作到今天上午!
这里是我的服务器规格: 的Windows 2008 R2 64位 的SQL Server 2008 64位
我已经安装了AccessDatabaseEngine_x64.exe。
Sql Server正在LocalService帐户下运行。 我已经设置每个人拥有“C:\ Temp”以及“C:\ Windows \ ServiceProfiles \ LocalService \ AppData \ Local”的FullControl权限。
有什么我错过了吗?我真的很迷茫......
编辑: 我也执行以下语句:
sp_configure ‘show advanced options’, 1;
GO
RECONFIGURE;
GO
sp_configure ‘Ad Hoc Distributed Queries’, 1;
GO
RECONFIGURE;
GO
EXEC master.dbo.sp_MSset_oledb_prop N’Microsoft.ACE.OLEDB.12.0′, N’AllowInProcess’, 1
GO
EXEC master.dbo.sp_MSset_oledb_prop N’Microsoft.ACE.OLEDB.12.0′, N’DynamicParameters’, 1
GO
我也用管理员帐户测试ACE.OLEDB.12.0
:
SELECT * FROM
OPENROWSET('MICROSOFT.ACE.OLEDB.12.0','Text;Database=C:\Temp\;','SELECT * FROM [test.csv]')
还有另一种错误:
OLE DB provider "MICROSOFT.ACE.OLEDB.12.0" for linked server "(null)" returned message "Unspecified error".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "MICROSOFT.ACE.OLEDB.12.0" for linked server "(null)".
最后我发现它: 我运行ProcMon,我看到Sql Server想访问F:\ Windows Temp \并且该文件夹不存在!我创建了该文件夹并解决了问题。但是,我从来没有这样的文件夹!
您是使用'ACE.OLEDB.12.0'还是'JET.OLEDB.4.0'?在x64版本的服务器上,您需要使用'ACE.OLEDB.12.0'。 – wqw 2012-03-13 16:44:02
我使用的是ACE.OLEDB.12.0,它工作了一年之前。是否有任何Windows更新导致此问题?我只是尝试JET.OLEDB.4.0来测试写在一些博客。 – 2012-03-14 05:45:13
您是否在用户帐户安全上下文中启动SQL Server服务? – wqw 2012-03-14 12:07:58