March 9, 2006 at 1:24 pm
I have a database table and one of its column is called case_Details of data type text. I need to modify the content of this column for one of the record.
I have 1200 records and the table has an identity column(ID1) and I need to modify the content of the row#954(which is called ID1).
How can I do this.
Thanks.
March 9, 2006 at 1:36 pm
What exactly you did not understand in BOL article "UPDATETEXT"?
_____________
Code for TallyGenerator
March 13, 2006 at 8:46 am
UPDATETEXT will update the part of the text but I want something different.
say my text column has a string 'abcdefghijklmnopqrstuvwxyz'
I need add 'STIRNGCHANGE' in place of 'fgh' of the original string.
So modified string(of data type text) should be like this.
'abcdeSTIRNGCHANGEijklmnopqrstuvwxyz'
Thanks.
March 13, 2006 at 9:37 am
Actually updatetext does just that "exactly"
declare @startIndex int, @patlength int, @prtval varbinary(16)
set @patLength = 3 --len('fgh')
SELECT @prtval = TEXTPTR(case_Details) , @startIndex = PATINDEX('%fgh%', case_Details)
FROM yourtable
WHERE pk_id = 1234 -- Use your primary key
and PATINDEX('%fgh%', case_Details) > 0 -- make sure it exists
if @@rowcount = 1
updatetext yourtable.case_Details, @prtval @startIndex @patLength 'STIRNGCHANGE'
good luck
* Noel
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply