views:

1854

answers:

3

What is the best way to append to a text field using t-sql in Sql Server 2005?

With a varchar I would do this.

update tablename set fieldname = fieldname + 'appended string'

But this doesn't work with a text field.

+1  A: 

This should work (link)

Joe
I wish there was an easier way, but thanks for the link.
Paul D. Eden
+1  A: 

in 2005 you should use varchar(max) or nvarchar(max) these columns will work with normal varchar functions. Text and ntext have been deprecated

SQLMenace
+2  A: 

Try this:

update 
  tablename
set
  fieldname = convert(nvarchar(max),fieldname) + 'appended string'
Bravax
Thanks Bravax, this was perfect!
Paul D. Eden
Well, at least I knew it was some sort of conversion error. :) Thanks Bravax.
Craig