Frequently Asked Questions - SQL Server 2005 - VARCHAR(MAX), NVARCHAR(MAX), VARBINARY(MAX)



What are the new data types or enhanced data types in SQL Server 2005??


What’s the maximum length for VARCHAR(MAX), NVARCHAR(MAX) and VARBINARY(MAX) data types?


Since you can use VARCHAR(MAX), can I define any length for a VARCHAR data type such as VARCHAR(10000)?


Will VARCHAR(MAX), NVARCHAR(MAX) and VARBINARY(MAX) replace TEXT, NTEXT and IMAGE data types?


 

Can I declare a local variable of VARCHAR(MAX), NVARCHAR(MAX) or VARBINARY(MAX)?


If there are VARCHAR(MAX), NVARCHAR(MAX) and VARBINARY(MAX) data types, are there also CHAR(MAX), NCHAR(MAX) and BINARY(MAX) data types?


How can I make sure that my VARCHAR column will only contain 10,000 characters?  Defining it as VARCHAR(10000) generates an error of "The size (10000) given to the type 'varchar' exceeds the maximum allowed for any data type (8000)."


Microsoft SQL Server 2005 introduces a new data type, the XML data type.  The XML data type lets you store XML documents and fragments in a SQL Server database.  An XML fragment is an XML instance that is missing a single top-level element.  You can create columns and variables of XML type and store XML instanced in them.

In addition to the new XML data type, Microsoft SQL Server 2005 has enhanced three of the existing SQL Server data types, namely the VARCHAR(MAX),NVARCHAR(MAX) and VARBINARY(MAX) data types.  The VARCHAR(MAX)data type indicates that the maximum storage size for the VARCHAR data type is 2^31-1 bytes.  The NVARCHAR data types indicates that the maximum storage size fr the NVARCHAR data type is 2^31-1 bytes.  Lastly, the VARBINARY(MAX) data type indicates that the maximum storage size for the VARBINARY data type is 2^31-1 bytes.