Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Cast/Append question

Author  Topic 

WJHamel
Aged Yak Warrior

651 Posts

Posted - 2011-11-15 : 10:33:24
I have a series of strings that i need to append to current data in a column with a TEXT value. I know that i need to cast this column as a VARCHAR(MAX) first, but i'm confused about how to then append my string to the data currently in that field. The column is part of the EVIDENCE database in the EVP_PRP table and with the column name is NOTE. The data that needs to be appended to the NOTE column is in the TEST column and needs to append according to a match in the value in the EVPNO column in the same table. So, where EVIDENCE..EVP_COC.EVPNO ='RCSO00EVP000476', the value of 'Notes from the COC Event column prior to conversion indicate: Return to owner'.

So how would i write the Cast/Append statement to accomplish this for the NOTE column?

Thanks!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-15 : 10:49:40
[code]
DECLARE @ptrval binary(16),@Len int,@AppendedNote varchar(2000)

SELECT @ptrval = TEXTPTR(NOTE),@Len=DATALENGTH(NOTE), @AppendedNote=TEST
FROM EVIDENCE..EVP_PRP pr
INNER JOIN EVIDENCE..EVP_COC p
ON p.EVPNO = pr.EVPNO
WHERE p.EVPNO ='RCSO00EVP000476'
UPDATETEXT EVIDENCE..EVP_PRP.pr_info @ptrval @Len 0 @AppendedNote
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

WJHamel
Aged Yak Warrior

651 Posts

Posted - 2011-11-15 : 11:06:37
Very helpful. Thank you.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-15 : 11:08:12
wc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -