3

I have a table with a field ,description nvarchar(200).

I am inserting string with a lot of lines.

When I take quick watch over the string in visual studio, I can see the string splited over mutile lines as i expected.

line1
line2
line3

But when I insert to database using a stored procedure,all "\n\r" beomes just spaces. When I read from the databse there is no "\n\r"

what can i do?

1
  • Is the stored procedure removing char #10 #3 and replacing them with spaces. Commented Apr 11, 2011 at 17:08

4 Answers 4

14

It should be stored just fine. When you look through SSMS, it removes the newlines for readability in its grid.

Sign up to request clarification or add additional context in comments.

Comments

2

From this answer

char(13) is CR. For DOS-/Windows-style CRLF linebreaks, you want char(13)+char(10), like:

'This is line 1.' + CHAR(13)+CHAR(10) + 'This is line 2.'

Comments

1

Use CHAR(13)

Refer to: CHAR

Comments

0

its best to use System.Environment.NewLine

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.