Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to increase value of a "TEXT" variable in a table

Status
Not open for further replies.

Plato2

Programmer
Dec 6, 2002
192
US
I have a table with a field that is declared as a TEXT variable. But I cannot update the value of that variable - I need to append additional varchar value to this text field but I cannot do that. Is there is a way to solve the problem?

Thanks in advance
 
For example I try to use an update statement to change the value of a column that is declared as TEXT

CREATE TABLE SomeTable
(
TextColumn Text
)
update SomeTable
set TextColumn=TextColumn+' Append Some String'

doesn't work saying that I cannot use TEXT columns to appent - inavlid + operation......

Any solution to append this column?

Thanks
 
You can't append to a text field using the update statement like you can with a varchar field. You need to use the UPDATETEXT command.

Code:
declare @NewText as varchar(100)
declare @ptrval varbinary(16)
set NewText = 'New text data.'
select @ptrval = TEXTPTR({TextField})
from {Table}
where {Key} = @{Variable}
UPDATETEXT {Table}.{TextField} @ptrval null 0 @NewText

Denny
MCSA (2003) / MCDBA (SQL 2000)

--Anything is possible. All it takes is a little research. (Me)

[noevil]
(My very old site)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top