Printed 2016/05/31 12:51PM

Get MAXimum functionality


SQL 2005 provides a the new max specifier to be used with varbinary, varchar and nvarchar data types. You can use these in place of image, text and ntext data types respectively.

There are many things you can't do with text that will work with varchar or nvarchar:

declare @bigString text -- can't declare local text variables
declare @smallString varchar(1000)

set @bigString = 'abcde'  -- can't make assignments to text
set @smallString = left(@bigString,1) -- text can't be used in string functions

Using varchar(max), this will work:

declare @bigString varchar(max) -- size is unlimited!
declare @smallString varchar(1000)
set @bigString = 'abcde'
set @smallString = left(@bigString,1)

This is just one of the many new features of SQL 2005.


Copyright © 2002-2016 Simple Talk Publishing. All Rights Reserved. Privacy Policy. Terms of Use. Report Abuse.