Storing HTML in SQL Server

What data type should I use to store HTML content in SQL Server 2008?

It's for dynamic content for a CMS.

Answers


VARCHAR(MAX) if it's all going to be ascii-based, say for basic HTML tepmplates

NVARCHAR(MAX) if the HTML could contain any content

NVARCHAR will double your storage use as it uses double the amount of space as VARCHAR. HTML itself does not require NVARCHAR, only the content in-between the HTML tags could based on the language, etc..

Edit:

Many years on from giving this answer I almost always use NVARCHAR now if there is any between the tag content. Unicode is popular...

I only use VARCHAR if just storing simple html templates, eg tags and placeholders eg: <div><span>[PLACEHOLDER]</span><div>

Make the call based on your use-case..


Put it in an NVARCHAR(MAX) (or smaller). HTML is no different from other text.


Data type should I use to store HTML content in SQL Server 2008

You must used Nvarchar(Max) if you want to store multiple language text.

otherwise use VARCHAR(MAX) if you want to store English language text.

nvarchar(max) contain more amount of spance compare to varchar(max)


Need Your Help

How can I safely set the user principal in a custom WebAPI HttpMessageHandler?

asp.net .net asp.net-mvc security asp.net-web-api

For basic authentication I have implemented a custom HttpMessageHandler based on the example shown in Darin Dimitrov's answer here: https://stackoverflow.com/a/11536349/270591

ECONFLICT Unable to find suitable version for jquery Foundation

javascript jquery json zurb-foundation bower

I am trying to install Foundation but its continuously giving me conflict with Jquery