sql server 2000中的小数点四舍五入的问题
表一productid price
1 303.5
2 413.2现在想用update把price的值变成304、413(把小数点四舍五入)
,有时在2005下可以,但在2000下就不行了,还望高手解答一下,谢谢。。
表一productid price
1 303.5
2 413.2现在想用update把price的值变成304、413(把小数点四舍五入)
,有时在2005下可以,但在2000下就不行了,还望高手解答一下,谢谢。。
304 413.0
declare @T table (id int,price numeric(4,1))
insert into @T
select 1,303.5 union all
select 2,413.2select id,round(price,0) price
from @T/*
id price
----------- ---------------------------------------
1 304.0
2 413.0(2 row(s) affected)
*/
insert @tab values(1,303.7)
insert @tab values(1,303.5)
insert @tab values(2,413.2)
select * from @tabselect id,convert(int,price) from @tab
update price=convert(int,price) from @tab
select id , cast(price as numeric) from table
SELECT CAST(price + 0.5 AS int(4))
FROM tb