Search code examples
sqlsybaseisql

Replace doesn't work in Sybase


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


Solution

  • Assuming there is only one decimal point, you can do it this way:

       stuff(convert(varchar(255), chrgamt),
             charindex('.', ChrgAmt),
             1, NULL)