【发布时间】:2016-02-29 18:10:47
【问题描述】:
我将查询结果保存到 SQL Server 2008 中的表 my_table 中,然后想将表中的数据插入到 excel 2007 文件中。以下是我正在使用的查询-
INSERT INTO OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\testing.xls;',
'SELECT Name, Date FROM [Sheet1$]')
SELECT a, b FROM my_table
GO
显示以下错误
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.
【问题讨论】:
-
确保您已启用Ad Hoc Distributed Queries。请注意,这是一个服务器范围的设置。如果您的 SQL Server 是 64 位,还请查看this 问题。 Here 是有人使用较新的提供者的问题。
-
打开
testing.xls并查询表格有什么好处吗?拉而不是推? -
@BaconBits Ad Hoc Distributed Queries 选项似乎已在我的系统上启用。我已经用显示配置的快照更新了问题。
-
@Dick Kusleika 我不确定这是否是完成这项工作的最佳方式。如果您有建议,请发表评论!
标签: sql-server excel