问题描述
我应该使用什么数据类型在 SQL Server 2008 中存储 HTML 内容?
用于 CMS 的动态内容.
VARCHAR(MAX) 如果一切都基于 ascii,比如基本的 HTML 模板
NVARCHAR(MAX) 如果 HTML 可以包含任何内容
NVARCHAR 将使您的存储使用量增加一倍,因为它使用的空间量是 VARCHAR 的两倍.HTML 本身不需要 NVARCHAR,只有 HTML 标签之间的内容可以基于语言等.
从给出这个答案多年后,如果标签内容之间有任何内容,我现在几乎总是使用 NVARCHAR.Unicode 流行...
我只在存储简单的 html 模板时才使用 VARCHAR,例如标签和占位符
例如:
根据您的用例拨打电话..
What data type should I use to store HTML content in SQL Server 2008?
It's for dynamic content for a CMS.
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..
这篇关于在 SQL Server 中存储 HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!
相关推荐

大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)