April 30, 2008 at 5:55 am
Hello,
I would like to change a string that is saved in a longtext Field.
How can I replace the string with a new value.
Regards
Tom
April 30, 2008 at 6:16 am
Hello I've found a way to perform an update but this code will only update the varchar value at a given position. In this example you see that on position 13, in the field herstelnota there will be an update for the chars 13 14 15. The text will be 'bas' for these positions. But how can i now find the positions for a specific value in the text field.
Any Ideas
Regards
[font="Arial Black"]
EXEC sp_dboption 'Logmodules', 'select into/bulkcopy', 'true'
GO
DECLARE @ptrval binary(16)
SELECT @ptrval = TEXTPTR(herstelnota)
FROM CAT_RepairNote
where printid= '1'
UPDATETEXT CAT_RepairNote.herstelnota @ptrval 13 3 'bas'
GO
EXEC sp_dboption 'Logmodules', 'select into/bulkcopy', 'false'
[/font]
April 30, 2008 at 6:36 am
I have found a solution
With the function CHARINDEX I can find the startPosition of the string that I search and I know the lenght of the string so I can update the value like this ;).
EXEC sp_dboption 'Logmodules', 'select into/bulkcopy', 'true'
GO
declare @startIndex as int
select @startIndex = convert(int,CHARINDEX('test',herstelnota) )-1
from CAT_RepairNote where printid= '1'
DECLARE @ptrval binary(16)
SELECT @ptrval = TEXTPTR(herstelnota)
FROM CAT_RepairNote
where printid= '1'
UPDATETEXT CAT_RepairNote.herstelnota @ptrval @startIndex 4 ' tom denys '
GO
EXEC sp_dboption 'Logmodules', 'select into/bulkcopy', 'false'
GO
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply