Mark Struzinski Mark Struzinski - 1 year ago 119
SQL Question

How to insert a line break in a SQL Server VARCHAR/NVARCHAR string

I didn't see any similar questions asked on this topic, and I had to research this for something I'm working on right now. Thought I would post the answer for it in case anyone else had the same question.


I found the answer here:

You just concatenate the string and insert a CHAR(13) where you want your line break.


SET @text = 'This is line 1.' + CHAR(13) + 'This is line 2.'
SELECT @text

This prints out the following:

This is line 1.
This is line 2.