O'Reilly logo

Programming Microsoft® SQL Server™ 2008 by Leonard Lobel, Andrew Brust, and Stephen Forte

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The varchar(max) Data Type

The varchar(max), nvarchar(max), and varbinary(max) data types are extensions of the varchar, nvarchar, and varbinary data types that can store up to 2 gigabytes (GB) of data. They are alternatives to text, ntext, and image and use the max size specifier. Using one of these data types is easy—you just specify it in your CREATE TABLE statement (or in any variable declaration) with a (max) identifier, as in this example:

CREATE TABLE TableWithMaxColumn
 (Customer_Id int, CustomerLifeStory varchar(max))

All the standard T-SQL string functions operate on varchar(max), including concatenation functions SUBSTRING, LEN, and CONVERT. For example, you can use the T-SQL SUBSTRING function to read parts of the string (chunks), and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required