数值/小数数据类型SQL [英] Numeric/Decimal data type SQL

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

问题描述

大家好,

我在数据库表中有一列,将其设置为int.现在,我也希望它也采用十进制值.我应该使用哪种数据类型为数字/十进制,为什么?当我尝试将其数据类型从int转换为十进制时,我是收到此错误-

"tblProducts"表
-无法修改表格.
将int转换为数值数据类型的算术溢出错误.
该声明已终止.

帮助我将其转换为接受十进制值.

谢谢
Amit

解决方案

您必须将列的数据类型从int更改为小数.

您不能将double值插入到int中.


将datatpe更改为numeric(18,2).
这里2是最多两位小数,您可以根据自己的选择设置.

在更改过程中,它将显示数据截断,但不会从将int更改为数值

Hey everyone,

I have a column in my database table,its set to int.Now,i want it to take decimal values also.Which datatype Numeric/Decimal should i use & why.When i am trying to convert its datatype from int to decimal i am getting this error--

''tblProducts'' table
- Unable to modify table.
Arithmetic overflow error converting int to data type numeric.
The statement has been terminated.

help me converting it to accept decimal values.

Thanks
Amit

解决方案

You have to change the datatype of your column from int to decimal.

you can''t insert double value into the int..


change datatpe to numeric(18,2).
Here 2 is for upto two decimal place u can set as per ur choice.

During changing it will show truncation of data but it doesn''t effect from changin int into numeric


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

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