简体   繁体   English

SELECT查询SQL Server 2005中的新行

[英]new line into SELECT query sql server 2005

I want to do a new line in my sql select 我想在我的SQL选择中做一个新行

I try this but it won't work 我尝试了一下,但是行不通

SELECT '1' + char(13) + '2'

AND

SELECT '1' + char(13) + char(10) + '2'

it always return 12 它总是返回12

thanks for your answers in fact I try to export data from sql to TXT file but when I execute the bcp file it return concatenate rows 感谢您的回答,实际上我尝试将数据从sql导出到TXT文件,但是当我执行bcp文件时,它会返回连接的行

That's just the way SSMS displays the results. 这就是SSMS显示结果的方式。 If you copy the result out into Notepad, or as Lamak says choose Results to Text you should see the newlines in place. 如果将结果复制到记事本中,或者如Lamak所说,选择“将Results to Text您应该会看到换行符。

The new line is in your result. 新行出现在您的结果中。 If you copy and paste the result from your query into notepad, for example, you'll see 1, new line, 2. The reason you see 1 2 in your result in the results window is because you are returning 1 row. 例如,如果将查询的结果复制并粘贴到记事本中,则会看到1,换行,2。在结果窗口中的结果中看到1 2的原因是因为您要返回1行。 Notice that len('1' + char(13) + char(10) + '2') = 4, that is because your chars are present, it's just represented as a single row (with multiple lines in the row). 请注意len('1'+ char(13)+ char(10)+'2')= 4,这是因为存在您的字符,它仅表示为单行(该行中有多行)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM