Re: how to suppress zeroes after decimal point at the end in a value

From: Steve Kass (skass_at_drew.edu)
Date: 09/26/04


Date: Sun, 26 Sep 2004 00:57:51 -0400

See if this works:

select
  replace(rtrim(replace(
  replace(rtrim(replace(
    c1,'0',' ')),' ','0')
      ,'.',' ')),' ','.')
from test

Steve Kass
Drew University

hari wrote:

>hi thanks,
>
> but it is not working for whole number like ex:11120
> it is giving it as 11120. (with point at the end)
> how to do that.
>
>thanks,
>
>hari.
>
>
>>-----Original Message-----
>>see following example:
>>
>>drop table test
>>create table test(c1 decimal (15,5))
>>insert into test values (3.567000)
>>insert into test values (232233.567000)
>>insert into test values (3.567)
>>
>>query:
>>select c1,reverse(substring(reverse(cast(c1 as varchar
>>
>>
>(25))) ,
>
>
>>patindex('%[^0]%', reverse(cast(c1 as varchar(25)))) ,
>>len(cast(c1 as varchar(25))) - (patindex('%[^0]%',
>>
>>
>reverse(cast(c1 as
>
>
>>varchar(25)))) - 1)
>>)) 'no_zeros'
>>
>>
>>from test
>
>
>>--
>>Vishal Parkar
>>vgparkar@yahoo.co.in | vgparkar@hotmail.com
>>
>>
>>.
>>
>>
>>



Relevant Pages