SQL查询和SELECT函数带有新行 [英] SQL Query and SELECT function with new line

查看:79
本文介绍了SQL查询和SELECT函数带有新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在串联行,并且我希望将行排成不同的行,而不要使用逗号将它们分开:

I am concatenating rows, and I want a row in different lines instead using a comma to separate them:

Persons
Sam
Rob
Bob
Tom
Tim 
/* something like that in the same row*/


我正在使用


I am using,

SELECT Person + CHAR(10) AS [text()]


但唯一要做的是,在每个新行之间都留有一个空格.


but what only does is, works as a space between each new row.

Any hint?

推荐答案

如果要在不同行中显示数据,则可以使用简单的select查询(假设数据位于单独的行中):
If you want data in different lines then simple select query will work (assuming the data is in separate row):
<br />
SELECT Person from table_name<br />



如果要将行连接为单列,请检查以下文章:

http://数据库. aspfaq.com/general/how-do-i-concatenate-strings-from-a-column-into-a-single-row.html [ http://www.simple-talk.com /sql/t-sql-programming/concatenating-row-values-in-transact-sql/ [ http://blog.sqlauthority.com/2007/08/22/sql-server-t-sql-script-to-insert-carriage-return-and-new-line-feed-in-code/ [



If you want to concatenate the rows to single column, then check the following article:

http://databases.aspfaq.com/general/how-do-i-concatenate-strings-from-a-column-into-a-single-row.html[^]

http://www.simple-talk.com/sql/t-sql-programming/concatenating-row-values-in-transact-sql/[^]

For new line, use
char(13) instead of char(10)

more info:
http://blog.sqlauthority.com/2007/08/22/sql-server-t-sql-script-to-insert-carriage-return-and-new-line-feed-in-code/[^]


这篇关于SQL查询和SELECT函数带有新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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