declare @i numeric(18,6)
set @i=0.32
select REVERSE(substring(REVERSE(@i),patindex('%[1-9]%',REVERSE(@i)),len(REVERSE(@i))))

解决方案 »

  1.   

    declare @i numeric(18,6)
    set @i=0.32
    select 结果=REVERSE(substring(REVERSE(@i),patindex('%[1-9]%',REVERSE(@i)),len(REVERSE(@i))))
    /*   
    结果                                       
    ---------------------
    0.32(1 row(s) affected)
    */
      

  2.   

    declare 
    @i numeric (18,6),
    @int int,
    @str varchar(10)
    set @i=0.32
    set @int =len(@i)
    while(@int > 0)
    begin
    print substring(cast(@i as varchar),@int,1)
    if(substring(cast(@i as varchar),@int,1)<>'0')
    begin
    set @str = substring(cast(@i as varchar),0,@int+1)
    break
    end
    set @int=@int-1
    end
    print @str