TSQL-将结果导出到 Excel 返回单线程公寓模式错误

发布于 2024-09-08 00:40:55 字数 642 浏览 1 评论 0原文

我想将结果从存储过程导出到 Excel。因此,在 exec 和 SELECT 语句之间插入以下内容:

INSERT INTO OPENROWSET('Microsoft.Jet.OLEDB.4.0', 
'Excel 8.0;Database=C:\Temp\testing.xls;', 
'
SELECT Field1, Field2, Field3
FROM [Sheet1$]
')

返回以下错误:

OLE DB 提供程序 'Microsoft.Jet.OLEDB.4.0' 无法用于分布式查询,因为该提供程序配置为在单线程单元模式下运行。

作为基本测试,我应该能够运行以下查询,该查询返回相同的错误:

INSERT INTO OPENROWSET('Microsoft.Jet.OLEDB.4.0', 
'Excel 8.0;Database=C:\temp\testing.xls;', 
'SELECT Name, Date FROM [Sheet1$]') 
SELECT [Name], GETDATE() FROM msdb.dbo.sysjobs
GO

我正在使用 SQL Server 2008 并且不使用 SSRS。关于如何解决这个问题有任何提示吗?

谢谢。

I want to export the results from a sproc to Excel. Thus, between the exec and SELECT statements I insert the following:

INSERT INTO OPENROWSET('Microsoft.Jet.OLEDB.4.0', 
'Excel 8.0;Database=C:\Temp\testing.xls;', 
'
SELECT Field1, Field2, Field3
FROM [Sheet1$]
')

Which returns the following error:

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.

As a basic test, I should be able to run the following query, which returns the same error:

INSERT INTO OPENROWSET('Microsoft.Jet.OLEDB.4.0', 
'Excel 8.0;Database=C:\temp\testing.xls;', 
'SELECT Name, Date FROM [Sheet1$]') 
SELECT [Name], GETDATE() FROM msdb.dbo.sysjobs
GO

I'm using SQL Server 2008 and am not using SSRS. Any hints on how to get around this?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

红玫瑰 2024-09-15 00:40:55

巴里已经在评论中回答了这个问题,只是跟进并发布支持 链接

This is answered already in the comments by Barry, just following up and posting answer with supporting link.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文