storing html in database

what are the best practices for storing html in database ( if at all )? should it be stored as html ( in a varchar max field ) or converted to xml ( in which case how should the conversion be handled )? thanks

more ▼

asked Mar 31, 2010 at 08:01 PM in Default

avatar image

user-1497 (google)
1 1 1 1

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

If you really must store HTML then store it as HTML in a varchar(max). If you store it as XML then as you say something somewhere needs to convert it, and I doubt you would be using any of the XML support in SQL.

In the past I have stored raw HTML (and compressed HTML) in varchar(max).

If it's not real data, then just think of it as a piece of data, and you just need a datatype big enough to store it.

more ▼

answered Mar 31, 2010 at 08:07 PM

avatar image

Kev Riley ♦♦
66.8k 48 65 81

  • Great explanation.

Mar 31, 2010 at 11:33 PM Tom Staab ♦
  • agreed with this assertion.

Apr 01, 2010 at 02:16 AM CirqueDeSQLeil
  • yup .

Apr 01, 2010 at 03:42 AM Fatherjack ♦♦

I definitely wouldn't try converting it in any way. That would add overhead to both saving and fetching, and something is bound to end up getting mangled sooner or later.

Apr 01, 2010 at 06:03 AM David Wimbush
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: Mar 31, 2010 at 08:01 PM

Seen: 3335 times

Last Updated: Mar 31, 2010 at 08:01 PM

Copyright 2018 Redgate Software. Privacy Policy