How to remove leading and trailing zeros in SQL Server 2008 -


i'm using sql server 2008 format function not available. there succinct way of removing leading , trailing zeros decimal.

other answers have found on stack overflow don't cover scenarios.

i want able this:

declare @d decimal(9,6) = 12.345 select removezeros(@d) 

i realise result string.

it should work of following cases:

0.123000    -> 0.123 1.23        -> 1.23 012.003450  -> 12.00345 1.00        -> 1 

create table #t(id decimal(9,6)) insert #t values(0.123000),(012.3879000),(1.23),(1.00)  select cast(id float) #t 

demo


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -