Reputation: 13843
I have some text,
e.g
line one \r\n
line two \r\n
line threee.
In my database, I have a column define as type text
, then I use Entity Framework to map that column, the code generate by Entity Framework is type string
I can successfully save that text into the column in the database. However, from Management Studio, I couldn't see those line separators, when I do copy value, and paste to notepad, they have become one line of text.
Anyone know what the problem is?
Thanks.
Upvotes: 1
Views: 4304
Reputation: 2775
You should stick to NVarchar when it comes to store text data (one of the reason is that it supports more characters). Heres an extract from msdn:
"ntext, text, and image data types will be removed in a future version of Microsoft SQL Server. Avoid using these data types in new development work, and plan to modify applications that currently use them. Use nvarchar(max), varchar(max), and varbinary(max) instead".
More info:
Upvotes: 0
Reputation: 700382
The problem is simply that Management Studio doesn't support all characters. It removes the line breaks when you copy the value.
If you change the result from grid to text (Query -> Results To -> Results to text, or ctrl+T), and select the value, you will see that the text comes out as separate lines.
Upvotes: 4
Reputation: 39023
This could quite simply be a problem with the management studio. Try querying the database from C# and printing the field's value. You will see immediately if the CRLFs are there.
Upvotes: 0