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
如果不需要四舍五入,则可以这样select cast(floor(34.345*100)/100 as dec(18,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