您的位置:首页 > 数据库

sql server 中对小数进行保留位数

2017-12-14 00:00 459 查看
摘要: 对数字进行保留位数

1.效果

select cast(round(12.1255587156,2) as numeric(20,2)) as value







2.将其他类型的数据转化为 字符串类型

-- 结果是float类型
select cast(round(12.1255587156,2) as numeric(20,2)) as value

-- 结果是 字符串类型了
select convert(varchar,cast(round(12.1255587156,2) as numeric(20,2)) ) as value

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息