SQL line break not working

后端 未结 6 1354
梦如初夏
梦如初夏 2021-01-29 15:05

I have below code:-

DECLARE @NewLineChar AS CHAR(23) = CHAR(13) + CHAR(10)
select \'abc\'+@NewLineChar+\'a\'

I expect the result to be:-

<
6条回答
  •  盖世英雄少女心
    2021-01-29 15:54

    It will work. But you have to see the result in Result to text output

    select 'abc'+ CHAR(13) +'a'
    

    When using the results to grid option, SSMS use the standard Windows grid control to display the results. This grid control treats each cell value as a plain text and hence the new line characters are ignored.

    However if you use the results to text option or the results to file the new line characters are retained.

    Refer : https://connect.microsoft.com/SQLServer/feedback/details/381955/sql-server-management-studio-should-show-new-lines-in-records

    Enable Result to text by pressing ctrl + t then run

提交回复
热议问题