TSQL : Set Line Breake on String

In TSQL, you can add line breaks to a string by using the CHAR(13) or CHAR(10) character.

For example, the following code will create a string with line breaks:

DECLARE @text AS VARCHAR(MAX) = ‘Line 1’ + CHAR(13) + ‘Line 2’ + CHAR(10) + ‘Line 3′
SELECT @text

The CHAR(13) character represents a Carriage Return (CR) and the CHAR(10) character represents a Line Feed (LF). When used together, they create a line break.

Alternatively, you can use the NCHAR function to add Unicode characters, for example:

DECLARE @text AS NVARCHAR(MAX) = N’Line 1′ + NCHAR(13) + N’Line 2′ + NCHAR(10) + N’Line 3’
SELECT @text

Scroll to Top