Sql 查询中的新行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1085662/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 02:41:17  来源:igfitidea点击:

New line in Sql Query

sql

提问by KuldipMCA

How you get new line or line feed in Sql Query ?

如何在 Sql Query 中获得换行或换行?

回答by Santosh Chandavaram

Pinal Dave explains this well in his blog.

Pinal Dave 在他的博客中很好地解释了这一点。

http://blog.sqlauthority.com/2009/07/01/sql-server-difference-between-line-feed-n-and-carriage-return-r-t-sql-new-line-char/

http://blog.sqlauthority.com/2009/07/01/sql-server-difference-between-line-feed-n-and-carriage-return-rt-sql-new-line-char/

DECLARE @NewLineChar AS CHAR(2) = CHAR(13) + CHAR(10)
PRINT ('SELECT FirstLine AS FL ' + @NewLineChar + 'SELECT SecondLine AS SL')

回答by Eric Falsken

-- Access: 
SELECT CHR(13) & CHR(10) 

-- SQL Server: 
SELECT CHAR(13) + CHAR(10)

回答by jvanderh

You could do Char(13)and Char(10). Cr and Lf.

你可以做Char(13)Char(10)。Cr 和 Lf。

Char()works in SQL Server, I don't know about other databases.

Char()在 SQL Server 中工作,我不知道其他数据库。

回答by Vinit Prajapati

use CHAR(10)for New Line in SQL
char(9)for Tab
and Char(13)for Carriage Return

使用CHAR(10)在SQL新线
char(9)的标签
,并Char(13)为回车