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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Concat Text

Status
Not open for further replies.

jazerr

Programmer
Dec 13, 2000
152
0
0
US
I need to concatenate TEXT. The concatenation will ALWAYS happen at the end of the existing text. ALWAYS.

I cannot make heads or tails of the UPDATETEXT stuff.

Anybody can help?
 
Does this make it any clearer?

Code:
create table my_comments (pkid int not null identity(1,1), comments text)
GO

set nocount on

declare @ptrval binary(16),
	@current_comment_len int,
	@new_comment varchar(8000),
	@pkid int

select @pkid = 1 --or whatever you need it to be to test

select @new_comment = 'this is my new comment'

if exists (select * from my_comments where pkid = @pkid)
	begin

	select @current_comment_len = datalength(comments)
	from my_comments
	where pkid = @pkid	

	select @ptrval = textptr(comments) 
	from my_comments
	where pkid = @pkid

	updatetext my_comments.comments @ptrval @current_comment_len 0 @new_comment

	end

else
	begin
	insert into my_comments (comments) values (@new_comment)
	end

set nocount off

select * 
from my_comments
where pkid = @pkid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top