Use varbinary(max) to store HTML? SQL Server 2008 - sql

I am trying to figureout the best solution to store html data in some of my tables and track the history of changes made to that HTML. I read that text, ntext, etc are no longer supported for AFTER Triggers so I was thinking of using the varbinary(max) instead. Has anyone used varbinary to store HTML? I was planning on tracking the changes using a trigger to write off the history when the HTML is updated.
As always I greatly appreciate the input....the feedback I get is always great.
Thanks,
S

using varchar(max) would be more logical - it is made for textual data and you can us string processing functions with it.

Why not varchar(max) or nvarchar(max) instead?

Related

Storing 30k-char strings, should I use NVARCHAR(max)?

From what I fond on internet, I should be using NVARCHAR(max) to store some strings that contain up to 30k characters. I don't need to search through the strings, only store and retrieve it. The type TEXT seems obsolete, and VARCHAR isn't as friendly as NVARCHAR about Unicode, so I should be using NVARCHAR(max), right ?
Secondly, for now I'm using some sql database of a free webhosting service, i'm creating the structure via the phpmyadmin, and when creating columns it doesn't suggest NVARCHAR, only VARCHAR and other types. Is NVARCHAR still available, maybe with a DDL command ? The sql version is 5.5.32
Thanks and sorry if my questions are unclear, i'm kind of a newb

SQL: Alternative to text and ntext data type?

I'm currently designing a MS SQL table for use in a project. The problem I'm currently facing is that the data types of "Transact SQL " are pointing to the deprecation of the types "text" and "ntext", which I always used for big texts.
Char, nchar, varchar and nvarchar may only be 8000 bytes big, this just isn't enough for a user input text, e. g. if he's writing a big article.
Is there any alternative to the obsolete data type text/ntext?
Using nvarchar(MAX) will allow you to store up to 2 GB of data. The same goes for varchar(MAX) too.
varchar(MAX) and nvarchar(MAX). Try 'em; you'll like 'em.
If you finished reading the paragraph on the MSDN page you linked, which explained that they were being removed, you would have found your answer:
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.
If you're using SQL 2005+, you could use n / varchar(max) instead. nvarchar will use unicode, and varchar will use ascii. If this is used to store blog text, then I would go with nvarchar(max)

What is the best SQL type to use for a large string variable?

Apologies for the rather basic question.
I have an error string that is built dynamically. The data in the string is passed by various third parties so I don't have any control, nor do I know the ultimate size of the string.
I have a transaction table that currently logs details and I want to include the string so that I can reference back to it if necessary.
2 questions:
How should I store it in the database?
Should I do anything else such as contrain the string in code?
I'm using Sql Server 2008 Web.
If you want to store non unicode text, you can use:
varchar(max) or nvarchar(max)
Maximum length is 2GB.
Other alternatives are:
binary or varbinary
Drawbacks: you can't search into these fields and index and order them
and the maximum size : 2GB.
There are TEXT and NTEXT, but they will be deprecated in the future,
so I don't suggest to use them.
They have the same drawbacks as binary.
So the best choice is one of varchar(max) or nvarchar(max).
You can use SQL Server nvarchar(MAX).
Check out this too.
Eventualy, you can enable and use a FILESTREAM feature of SQL Server 2008 (it's supported by WEB edition), and deal with extra large amount of data in sense of documents.
Of course, you need to be sure that you will use a benefit of this service.

How to manipulate TEXT, NTEXT data from sql server trigger

i hard that TEXT, NTEXT data can not be manipulated from sql server trigger. is it true. if not then please explain how could i manipulate TEXT, NTEXT data from sql server trigger.
thanks
Don't use text or ntext. Use nvarchar(max) or varchar(max)
Harsh, but they have been deprecated for a reason...
Edit, just remembered. You may be able to use INSTEAD OF triggers

Can source code examples be kept in a SQL database while retaining all formatting? If so

Can source code examples be kept in a SQL database while retaining all formatting (tabs, newlines, etc.)? If so what data type would be used?
Yes, use a TEXT type (or MEDIUMTEXT or LONGTEXT - you get the idea)
A BLOB type (varbinary) would definitely work, although databases shouldn't mangle text that's stored as varchar either.
The best in Sql Server: nvarchar(max)
You can upload this into a blob data type. SQL 2008 comes with the capability of storing the entire executable file in the database.