SQL line break not working

后端 未结 6 1363
梦如初夏
梦如初夏 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:59

    Try using PRINT and not SELECT to display the result.

    DECLARE @NewLineChar AS VARCHAR(23) = CHAR(13) + CHAR(10)
    PRINT 'abc'+@NewLineChar+'a'
    

    (Don't forget to move to the Messages tab to view the result)

    The SSMS grid display does not display line breaks or newline characters.

提交回复
热议问题