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

From: Vishal Parkar (REMOVE_THIS_vgparkar_at_yahoo.co.in)
Date: 09/23/04


Date: Thu, 23 Sep 2004 12:42:55 +0530

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