A direct insert of an arbitrary varchar string should always work:
create table MarkupTable(
id int identity(1,1) /*please don't berate me for using identity!*/
, markup varchar(max) /* this will use only the space taken by your markup string */
)
insert MarkupTable select '<html><b>demo</b></html>'
select * from MarkupTable
Now - the question is: what piece of code is encoding your markup???
Some starting places:
- Are you using C# objects properly: SqlParameter(SqlDbType.VarChar).Value = yourMarkupString;
- Are you using FOR XML anywhere?
- Are you using anything like Security.Escape(markup)?
- Is your string being returned as part of an XmlDocument or SOAP envelope? (it WILL be escaped by the serializer)
- Are you getting a doubly encoded string?
Try:
Server.HtmlDecode(Server.HtmlDecode(markupString));
For space requirements:
- You could run the string through a whitespace stripping algorithm (anything becomes a single space or tab.
- You could compress the text and not even store varchar(max), but varbinary(max)