Fábio Antunes Fábio Antunes - 1 year ago 68
ASP.NET (C#) Question

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 store 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


Answer Source

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).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download