我有一个存储过程,返回的值有可能是4.234 ,34.345,0.24 等等,但是我要取得就是整数加小数点后的两位,也就是4.23,
,34.34,0.24这样的值,应该怎么做?  谢谢了、、

解决方案 »

  1.   

    把你的output参数改为decimal(10,2)就可以了。
      

  2.   


    declare @table table (id varchar(10))
    insert into @table
    select 4.234 union all
    select 34.345 union all
    select 0.24select cast(id as decimal(16,2)) as id from @tableselect substring(id,1,charindex('.',id)+2) as id from @tableid
    ---------------------------------------
    4.23
    34.35
    0.24
    id
    ----------
    4.23
    34.34
    0.24
      

  3.   

    如果不需要四舍五入,则可以这样select cast(floor(34.345*100)/100 as dec(18,2))