JCIsola
JCIsola

Reputation: 108

Is it possible to replace text by other text in SqlBase?

Is it possible to replace text in a SqlBase? I found there is a @REPLACE function but I see it just replaces using positions in the string:

The following expression returns the value 'RALPH':

@REPLACE('RALF', 3, 1, 'PH')

What I need is to replace a substring by another, In Sql Server it's like this:

This returns 'ABA':

SELECT REPLACE('ABC', 'C', 'A')

Thanks!

Upvotes: 0

Views: 184

Answers (1)

Steve Leighton
Steve Leighton

Reputation: 840

Using the literals in your 'ABC' to 'ABA' example....

Select @REPLACE( 'ABC', @FIND( 'C', 'ABC', 0 ), @LENGTH('C'),  'A' )

Using the literals in your 'RALF' to 'RALPH' example....

Select @REPLACE( 'RALF', @FIND( 'F', 'RALF', 0 ), @LENGTH('F'),  'PH' )

Upvotes: 1

Related Questions