Search code examples
databaseplsqlsybasesap-ase

Sybase Replace Function Issue


I have statement

SET @abc = 'ankit kumar'
SET @xyz = 'rohit'
SET @abc = SELECT REPLACE(@abc, 'ankit', @xyz)

but it not working and giving error: Incorrect syntax near the keyword 'SELECT'. I have also tried below instead of 3rd line but it doesn't work either:

SET @abc = REPLACE(@abc, 'ankit', @xyz)

Please assist. I am using Sybase ASE


Solution

  • Try this:

    declare @abc varchar(100)
    declare @xyz varchar(100)
    
    SET @abc = 'ankit kumar'
    SET @xyz = 'rohit'
    set @abc =  str_replace(@abc, 'ankit', @xyz)