Question

In T-SQL (SQL Server 2008 and higher), what is the datatype to use for a column which stores text data keeping formatting like breaklines / enters, bullets, tabs etc. in the text? The length of the text can vary substantially.

I have tried NVarchar(max), but a select result set removes all the formatting. Or is this caused by SSMS like on this post here and this post?

Is it also possible to store the text data including the html code?

Sorry for the newbie question, but I saw a few posts on Stackoverflow that confuse me somewhat about this subject in respect which datatype is best to use: Ntext vs Nvarchar; and how to get the data out of the DB but still keep the formatting.

Thanks!

Was it helpful?

Solution

When you save information into SQL Server the information is stored at text, so when you try to insert HTML it is stored as raw HTML code.

From my knowledge there is no way to allow HTML formatting in a SQL Server result set.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top