It is fairly simple to eliminate trailing zeros and decimal points.
Select cast(cast(<value> as float) as varchar(5)) As VarOut
When <value>=5.00 this statement returns 5. However, when the whole number part of <value> = 0 (i.e., 0.20) this statement returns a leading zero. Eliminating the leading zero is slightly harder.
Select
Case
When left(cast(cast(@x as float) as varchar(5)),1)='0'
Then stuff(cast(cast(@x as float) as varchar(5)),1,1,'')
Else cast(cast(@x as float) as varchar(5))
End As VarOut
Perhaps, someone can create a more elegant solution. Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.