http://www.sqlservercentral.com/blogs/kathi_kellenberger/2005/11/12/get-maximum-functionality-/

Printed 2014/09/20 04:12AM

Get MAXimum functionality

2005/11/12

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-2014 Simple Talk Publishing. All Rights Reserved. Privacy Policy. Terms of Use. Report Abuse.