سؤال

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

هل كانت مفيدة؟

المحلول 3

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

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

نصائح أخرى

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 

Sybase ASE uses str_replace() instead of replace()

the problem of your query is the varchar(255), remove the 255 then should be fine

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

the best one i will recommended nvarchar instead of varchar , cheer

This works in "Ase":

select
  ChrgAmt
  , str_replace(convert(varchar(255),ChrgAmt), '.', null) as Result
from
  PaymentSummary
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top