我正在将查询结果保存到SQL server2008中的表my_table中,然后希望将表中的数据插入到excel2007文件中。下面是我使用的查询-
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.我怎么才能把这个修好?附注:我的系统上似乎启用了即席分布式查询。

发布于 2016-03-01 15:55:04
您需要在查询之前运行以下命令:
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.Jet.OLEDB.4.0', N'AllowInProcess', 1
GO
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.Jet.OLEDB.4.0', N'DynamicParameters', 1
GO在查询之后,如果需要,可以将此值设置为0。如果运行64位服务器,则需要使用Microsoft.ACE.OLEDB.12.0。
https://stackoverflow.com/questions/35706509
复制相似问题