在excel文件中导出sql查询结果 [英] Export sql query result in excel file
问题描述
嗨
我希望将我的sql查询结果保存为excel文件。
我使用bellow代码,但它无法正常工作:< br $>
Hi
I want save my sql query result as excel file.
I use from bellow code, but it doesn't work correctly:
insert into OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=D:\testing.xls;',
'SELECT * FROM [Sheet1$]')
select * from DataDictionary
我的错误:
消息7302,级别16,状态1,行1
无法为链接服务器创建OLE DB提供程序Microsoft.Jet.OLEDB.4.0的实例(null)。
我使用SQL Server 2012和Excel 2007.
请帮帮我,我如何将查询结果保存为excel文件?
非常感谢
My Error:
Msg 7302, Level 16, State 1, Line 1
Cannot create an instance of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)".
I use SQL Server 2012 and Excel 2007.
Please help me, How I can save result of my query as excel file?
Thanks a lot
推荐答案
')
select * from DataDictionary
') select * from DataDictionary
我的错误:
Msg 7302,Level 16,State 1,Line 1
无法为链接服务器创建OLE DB提供程序Microsoft.Jet.OLEDB.4.0的实例(null )。
我使用SQL Server 2012和Excel 2007.
请帮帮我,我怎么样可以将我的查询结果保存为excel文件吗?
非常感谢
My Error:
Msg 7302, Level 16, State 1, Line 1
Cannot create an instance of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)".
I use SQL Server 2012 and Excel 2007.
Please help me, How I can save result of my query as excel file?
Thanks a lot
看看这里:
通过链接服务器查询Excel文件源 [ ^ ]
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID= 49926 [ ^ ]
http://www.mssqltips。 com / sqlservertip / 1202 / export-data-from-sql-server-to-excel / [ ^ ]
示例:
Have a look here:
Query Excel file source through Linked Server[^]
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=49926[^]
http://www.mssqltips.com/sqlservertip/1202/export-data-from-sql-server-to-excel/[^]
Example:
insert into OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0;Database=D:\testing.xlsx;',
'SELECT * FROM [Sheet1
')
从 DataDictionary
') select * from DataDictionary
>
另一种方法是使用bcp和xp_cmdshell工具(到* .csv文件):
使用bcp和xp_cmdshell以编程方式导出数据 [ ^ ]
这篇关于在excel文件中导出sql查询结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!