Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Advice from Aunt Kathi

Kathi Kellenberger is a Sr. Consultant with Pragmatic Works. She is an author, speaker and trainer.

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.

 

Comments

No comments.

Leave a Comment

Please register or log in to leave a comment.