HTML is just text, so you store it in any of the text column types
(varchar, nvarchar, text, ntext).

I have a comment form in a site that lets people add HTML markup to
the comment. I take this text, clean up the HTML, and put it into two
columns, a comment_html column and a comment_plaintext column that has
the HTML markup removed. Both columns are of type varchar(max). The
reason to store one comment twice is that not everything supports
HTML, such as SQL Server Reporting Services and third-party grid
controls. Storing a plain text version also allows for a
left(comment,100) type of function to show a preview of a lengthy
comment and could help with a text search feature. Instead of
stripping out the HTML tags for every data retrieval, I strip them out
once during the insert, which increases the size of the database but
speeds up data retrieval.

The next most common method of storing HTML I believe is to store it
as XML. SQL Server 2005 introduced powerful and fast XML support,
although I would suspect this is overkill for what you are trying to
accomplish.

I hope that helps,
Mike Chabot

On Sat, Jan 17, 2009 at 11:21 PM, Torrent Girl <[email protected]> wrote:
>
> Hello All
>
> Does anyone know the best practice for storing HTML in a MS sql database?
>
> I did sme research and found one reference that recommended saving it as 
> plain text but I am not sure of what that means.
>
> Do I make the column that will hold the data a text column?
>
> Thnx
>
> tGirl

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:318139
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to