Write Function in SQL Server 2005

One of the functions available in SQL Server 2005 that allows you to update a character column of size max is WRITE Function. In fact we can consider this as alternate to STUFF function which wont work for columns with Max length

 

declare @t table(v nvarchar(max))

insert into @t select 'test is test'

update @t set v=stuff(v,1,4,'This')

select v from @t

 GO

declare @t table(v nvarchar(max))

insert into @t select 'test is test'

update @t set v.write('This',0,4)

select v from @t

PS

You can use STUFF function in both SELECT and UPDATE Statement but WRITE function can be used only in UPDAET statement preceded by Column name.

Published Tuesday, October 30, 2007 10:47 AM by Madhivanan
Filed under: , ,

Comments

No Comments