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?

Kuttan Sujith
  • 7,889
  • 18
  • 64
  • 95

4 Answers4

14

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

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
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.'
Community
  • 1
  • 1
Homam
  • 23,263
  • 32
  • 111
  • 187
1

Use CHAR(13)

Refer to: CHAR

Akram Shahda
  • 14,655
  • 4
  • 45
  • 65
0

its best to use System.Environment.NewLine

moi_meme
  • 9,180
  • 4
  • 44
  • 63