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.
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 ONDECLARE @TextPointer varbinary( 16 ) DECLARE @DeleteLength int DECLARE @OffSet int SELECT @TextPointer = textptr( Description)FROM Brodmann --Brodmann is a table only has 5 rowsSET @DeleteLength = len( @FindString ) SET @OffSet = 0WHILE ( SELECT count( * ) FROM Brodmann WHERE charindex( '%Brodmann-10%', Description) <> 0) > 0BEGIN SELECT @OffSet = charindex( '%Brodmann-10%', Description) -1FROM BrodmannWHERE charindex('%Brodmann-10%', Description) <> 0UPDATETEXT Brodmann.Description@TextPointer@OffSet@DeleteLength@ReplaceStringENDRETURN |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|