Blog Post

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.

 

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating