运行此代码时,SQL Server Management Studio 抛出错误:
declare @percentage numeric(3,2)
set @percentage = cast(15 as numeric(3,2))
但是当我将数字声明更改为
declare @percentage numeric(4,2)
set @percentage = cast(15 as numeric(4,2))
一切顺利。
数字数据类型有限制吗?
最佳答案
数字定义总位数,然后是小数点后的数字。
数字(3,2)最多只能容纳 9.99。
关于sql-server - 为什么 SQL Server 在将 int 转换为数据类型 numeric 时会抛出算术溢出错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2059134/