开发者

Best data type to store html css javascript

Good day.

I have a PHP & MySql background, and I'm just starting with ASP.NET. I don't have any background with ASP, only have experience with C#.

Well my problem its very simple, i would like to be able to save HTML, CSS and Javascript code directly to a MS SQL Server database.

However i don't know which data type is more advised to st开发者_运维问答ore code, bare in mind that i would like to keep the original code formatting (break lines, formating, etc).

Any help is appreciated.

Environment Details:

  • Windows 7 (x86)
  • Visual Studio 2010 Ultimate
  • Sql Server 2008
  • ASP.NET & C#
  • NET Framework 4.0

Thanks.


varchar(#) if you know you will not be storing unicode characters, if you are going to store unicode characters use nvarchar(#). Replace the # with the max number of characters. You can also specify max instead of a number and it will store as much as you want (there probably is a limit, but I haven't run into it yet).


Use the large text datatypes varchar(max) or nvarchar(max) which allow up to 2GB-1 bytes of data

From MSDN on text and ntext

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.


For future compatibility, use the VARCHAR(MAX) data type. In SQL Server 2005 Microsoft added support for varchar(max) and nvarchar(max), this new datatype can be used anywhere a regular length limited varchar can, but lets you store up to 2GB of data. Behind the scenes the varchar(max) stores up to as much of the text as it can in the row (up to 8K), and then creates additional pages for any additional text. So in a lot of cases the text content will fit in the row, requiring much less disk IO.

Microsoft is said to be deprecating the text and ntext data types in future releases.


You can use nText or Text
if you have unicode language in your html use nText
nText has unlimited lenght column for your data

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜