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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 update text in table column

Author  Topic 

ez689@live.com
Starting Member

2 Posts

Posted - 2008-01-12 : 03:41:57
need help on how to update a string in a table column. I want to replace 'Brodmann-10' with 'Brodmann-1910'. The following script does not work right. I appreciate your help

DECLARE @FindString varchar(80)
DECLARE @ReplaceString varchar(80)

SET @FindString = 'Brodmann-10'
SET @ReplaceString = 'Broadmann-1910'

SET NOCOUNT ON

DECLARE @TextPointer varbinary( 16 )
DECLARE @DeleteLength int
DECLARE @OffSet int

SELECT @TextPointer = textptr( Description)
FROM Brodmann --Brodmann is a table only has 5 rows
SET @DeleteLength = len( @FindString )
SET @OffSet = 0
WHILE ( SELECT count( * ) FROM Brodmann WHERE charindex( '%Brodmann-10%', Description) <> 0) > 0
BEGIN
SELECT @OffSet = charindex( '%Brodmann-10%', Description) -1
FROM Brodmann
WHERE charindex('%Brodmann-10%', Description) <> 0
UPDATETEXT Brodmann.Description
@TextPointer
@OffSet
@DeleteLength
@ReplaceString
END
RETURN

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-01-12 : 07:25:15
Duplicate of http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=95403

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -