OPENROWSET与Excel文件 [英] OPENROWSET with Excel file

查看:174
本文介绍了OPENROWSET与Excel文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想执行简单的语句:

  SELECT * FROM 
OPENROWSET('MICROSOFT.JET.OLEDB。 4.0','Text; Database = C:\Temp\;','SELECT * FROM [test.csv]')

突然我今天早上得到这个消息:

 消息7308,级别16,状态1,第1行
OLE DB提供程序'MICROSOFT.JET.OLEDB.4.0'不能用于分布式查询,因为提供程序配置为以单线程公寓模式运行。

它一直工作到今天上午!



这是我的服务器规格:
Windows 2008 R2 64位
SQL Server 2008 64位



我已经安装了AccessDatabaseEngine_x64.exe。 p>

Sql Server在LocalService帐户下运行。
我已经将Everyone设置为具有C:\Temp的FullControl权限以及C:\Windows\ServiceProfiles\LocalService\AppData\Local。



有没有什么我错过的?我真的很困惑...



已编辑:
我也执行了这些语句:

  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提供程序MICROSOFT.ACE.OLEDB.12.0用于链接服务器(null)返回消息未指定错误。 
消息7303,级别16,状态1,行1
无法初始化链接服务器(null)的OLE DB提供程序MICROSOFT.ACE.OLEDB.12.0的数据源对象。

最后我发现它:
我运行ProcMon,我看到了Sql Server想要访问F:\Windows Temp\并且该文件夹不存在!我创建了文件夹,问题解决了。但是,我从来没有这样的一个文件夹!!!

解决方案

ProcMon和我看到SQL Server想要访问 F:\Windows Temp\ ,该文件夹不存在!我创建了文件夹,问题解决了。但是,我从来没有这样的一个文件夹!!!


I want to execute simple statement:

SELECT * FROM 
OPENROWSET('MICROSOFT.JET.OLEDB.4.0','Text;Database=C:\Temp\;','SELECT * FROM [test.csv]')

And suddenly I get this message today morning:

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 was working till today morning!

Here is my server specs: Windows 2008 R2 64 bit SQL Server 2008 64 bit

I've installed AccessDatabaseEngine_x64.exe.

Sql Server is running under LocalService account. I've set Everyone to have FullControl permission to "C:\Temp" as well as "C:\Windows\ServiceProfiles\LocalService\AppData\Local".

Is there anything I missed? I'm really confused...

Edited: I've also executed these statements:

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

I've also tested ACE.OLEDB.12.0 with administrator account:

SELECT * FROM  
OPENROWSET('MICROSOFT.ACE.OLEDB.12.0','Text;Database=C:\Temp\;','SELECT * FROM [test.csv]')

There is another error:

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)".

Finally I found it: I ran ProcMon and I saw that Sql Server wants to access to F:\Windows Temp\ and the folder does not exist! I created the folder and the issue is solved. But, I never had such a folder!!!

解决方案

Finally I found it: I ran ProcMon and I saw that SQL Server wants to access to F:\Windows Temp\ and the folder does not exist! I created the folder and the issue is solved. But, I never had such a folder!!!

这篇关于OPENROWSET与Excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆