SQL Server的浮动数据类型 [英] Floating datatype of SQL Server

查看:100
本文介绍了SQL Server的浮动数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我将SQL数据库表中的值存储为浮点数。但我不需要一个长浮点数,只想在两位小数位显示它。谢谢

解决方案

尝试使用十进制数据类型 [ ^ ]喜欢这个十进制(5,2),范围< -999.99,+ 999.99>。


Hi


当您从数据库中获取数据时将其转换为两个小数点,如下所示



  SELECT  Col1,Col2,CAST(Col3  AS   DECIMAL  18  2 )) AS  Col3  FROM  TABLE1 









你必须转换你的代码。

 Math.Round(YourValue, 2 )。ToString (); 


Hello,

I am storing values in SQL Database table as floating point. But i dont need a long floating number, just want to display it in two decimal places. Thanks

解决方案

Try to use decimal data type[^] like this decimal(5, 2) for range <-999.99, +999.99>.


Hi
Convert it to two decimal points when you fetch data from database as follows

SELECT Col1, Col2, CAST(Col3 AS DECIMAL(18,2)) AS Col3 FROM TABLE1



Or

You have to convert in your code behind.

Math.Round(YourValue, 2).ToString();


这篇关于SQL Server的浮动数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆