What data type should I use to store HTML content in SQL Server 2008?
It’s for dynamic content for a CMS.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
VARCHAR(MAX)if it’s all going to be ascii-based, say for basic HTML tepmplatesNVARCHAR(MAX)if the HTML could contain any contentNVARCHAR 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..