Quantcast
Channel: Solved » sql-server
Viewing all articles
Browse latest Browse all 48

How to Insert a Line Break in a Sql Server Varchar/Nvarchar String

$
0
0

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.

Solution

I found the answer here: http://blog.sqlauthority.com/2007/08/22/sql-server-t-sql-script-to-insert-carriage-return-and-new-line-feed-in-code/

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

Example:

DECLARE @text NVARCHAR(100)
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.

The post How to Insert a Line Break in a Sql Server Varchar/Nvarchar String appeared first on Solved.


Viewing all articles
Browse latest Browse all 48

Trending Articles