SQL Server PRINT SELECT(打印选择查询结果)?

编程入门 行业动态 更新时间:2024-10-27 06:31:17
本文介绍了SQL Server PRINT SELECT(打印选择查询结果)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试打印选定的值,这可能吗?

I am trying to print a selected value, is this possible?

示例:

PRINT SELECT SUM(Amount) FROM Expense

推荐答案

您知道,也许有一种更简单的方法,但首先想到的是:

You know, there might be an easier way but the first thing that pops to mind is:

Declare @SumVal int; Select @SumVal=Sum(Amount) From Expense; Print @SumVal;

您当然可以通过这种方式从表格中打印任意数量的字段.当然,如果要打印返回多行查询的所有结果,只需将输出适当地定向(例如,定向到文本)即可.

You can, of course, print any number of fields from the table in this way. Of course, if you want to print all of the results from a query that returns multiple rows, you'd just direct your output appropriately (e.g. to Text).

更多推荐

SQL Server PRINT SELECT(打印选择查询结果)?

本文发布于:2023-10-20 22:17:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1512301.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:查询结果   Server   SQL   SELECT   PRINT

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!