views:

77

answers:

2

I'm working in a modified version of Sybase 10 that doesn't have the stuff, replace or str_replace functions. I need to replace part of string in a number of records.

Are there any creative ways to program around this, so I don't have to do them all manually?

Example:

UPDATE status
SET description = replace(description,'abc','def')
WHERE name = 'test'

EDIT: I've found that we have NO string-manipulation functions and I'll have to do exports and imports to do bulk string changes. I'll leave this question up so others who aren't quite restricted as I am will be able to find the answers.

A: 

A combination of charindex and substring should work for you.

RedFilter
+4  A: 
UPDATE status
SET description = SUBSTRING(description,1,CHARINDEX('abc',description)-1) 
                  + 'def' + 
                  SUBSTRING(description,CHARINDEX('abc',description)+CHAR_LENGTH('abc'),CHAR_LENGTH(description)-CHARINDEX('abc',description))
WHERE name = 'test'

Tricky and you have to put the text you want to change in few places, but it works ;-)

Lukasz Lysik