How to maintain line breaks in sql server

sql-server

Solution

You can use `CHAR(13)` for `line breaks` and `CHAR(10)` for `Line Feed (LF)`.

So what you can do is before inserting it into the database, replace each line breaks with `CHAR(13)`.

Here you go:

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

Problem

I have an asp.net textbox which has line breaks and the line breaks are not maintained in sql server 2008. How do I do this?

Original source