Skip to content
 

Insert Carriage Return Line Feed to String

Here is a clean and efficient way to embed carriage returns into a string. I prefer this way instead of concatenating the entire CHAR(13)+CHAR(10) to the end of every string. This replace function also comes in handy in most instances where you need to append strings.

declare @Note varchar (200)

SET @Note = 'Line One.[crlf];Line Two[crlf]Line Three.'

SET @Note = REPLACE(@Note,'[crlf]',CHAR(13)+CHAR(10))

PRINT @Note

Output:

Line One.
Line Two.
Line Three.

Related Posts:

Ask a question or post a comment