【发布时间】:2014-04-23 09:02:43
【问题描述】:
我正在尝试使用 sql 查询将 SQL 服务器数据导出到 excel 文件。但我收到错误
OLE DB provider "Microsoft.Jet.OLEDB.4.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.Jet.OLEDB.4.0" for linked server "(null)".
我正在使用的查询
select * from OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=C:\share\Test1.xlsx;HDR=YES','SELECT id FROM [Sheet1$]') SELECT id FROM Table
我也启用了
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Ad Hoc Distributed Queries', 1;
GO
RECONFIGURE
EXEC master.dbo.sp_MSset_oledb_prop 'Microsoft.Jet.OLEDB.4.0', 'AllowInProcess', 0
GO
EXEC master.dbo.sp_MSset_oledb_prop 'Microsoft.Jet.OLEDB.4.0', 'DynamicParameters', 0
GO
我还以完全权限共享了我的文件夹。 我给 Excel 文件提供了与表名相同的标题 但同样的错误
【问题讨论】:
标签: sql sql-server database excel export-to-excel