Posted By: VBJB | Dec 20th, 2006 @ 9:03 AM
page 1 of 1
Comments: 3 | Views: 2502
What is the best way to handle this?

I have a SP that needs to append data to a field that is type text. I wanted to do a query and place the value in a local variable in the SP and say Comment = @Comment + ' ' + @NewComment, but I cannot have a local variable in a SP that is type text.

How do I append data to a field that is type text in a Stored Procedure?

Thanks
There's UPDATETEXT, but it's not especially easy to use.  If you're certain the text is less than 8000 characters, you can cast it to a varchar.

I tried this and I get the same error:

Declare @NewComment varchar(250)

Set @NewComment = Cast((Select Delivery.Comment From Delivery Where Delivery.ID = 50) as varchar(250))

This works:

Set @NewComment = (Select Cast(Delivery.Comment as varchar(250)) From Delivery Where Delivery.ID = 50)
page 1 of 1
Comments: 3 | Views: 2502