Replace doesn't work in Sybase

SMPH picture SMPH · Aug 1, 2013 · Viewed 11k times · Source

I tried following in Sybase

SELECT ChrgAmt, REPLACE(convert(varchar(255),ChrgAmt), '.', '') AS Result
FROM PaymentSummary

But it gives below error in isql

Incorrect syntax near the keyword 'REPLACE'.

What could be the possible reason

Thanks

Answer

Robert picture Robert · Aug 1, 2013

On Sybase ASE there is str_replace funciotn

SELECT ChrgAmt, str_replace(convert(varchar(255),ChrgAmt), '.', '') AS Result
FROM PaymentSummary 

you can also use cast instead of convert as below

SELECT ChrgAmt, str_replace(cast(ChrgAmt as varchar(255)), '.', '') AS Result
FROM PaymentSummary