SQLServer-T-SQL脚本到Excel输出 [英] SQLServer - T-SQL Script To Excel Output

查看:92
本文介绍了SQLServer-T-SQL脚本到Excel输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何T-SQL代码可将输出传输到excel中?

Is there any T-SQL code to tranfer output into excel ?

推荐答案

您可以将结果输出为XML(假设您正在使用Excel 2007/10),将使用 FOR XML [SELECT 语句的target =" _ blank"title =" New Window> ^ ]子句.或者,您可以构造一个查询,以逗号分隔值(CSV)格式显示结果.

您应该知道,T-SQL命令是在SQL Server计算机上执行的,而不是在客户端上执行的.

因此,您的客户端应用将需要打开excel并将结果数据加载到电子表格中.
You could output your results as XML asumming you are using Excel 2007/10, which will read XML files, using the FOR XML[^] clause of your SELECT statment. Alternatively you could construct a query that results the results in a Comma Separated Values (CSV) format.

You should be aware the T-SQL commands are excuted on the SQL Server machine and NOT the client.

Therefore you client app will need to open excel and load the resulting data into a spreadsheet.


这篇关于SQLServer-T-SQL脚本到Excel输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆