为什么在将 bigint 数字插入 bigint 列时出现算术溢出错误?
Why I'm getting arithmetic overflow error when inserting bigint number to a bigint column?
我正在尝试向列中插入一个数字。列数据类型是 BIGINT,我很确定我的数字没有超过 BIGINT 的最大值,但我仍然得到
Msg 8115, Level 16, State 2, Line 40
Arithmetic overflow error converting expression to data type int.
The statement has been terminated.
我最近 activity 是我将该列的数据类型从 INT 更改为 BIGINT。我认为我的专栏在内部某处仍被定义为 INT。
这是我的脚本。
Insert into Customer(Cust_ID)
Select 2150000000
列 Cust_ID 数据类型在设计器中为 BIGINT。它也是 PRIMARY_KEY,许多 table 引用它。
编辑:
这是一些迁移脚本
DROP TABLE dbo.Customer
GO
EXECUTE sp_rename N'dbo.Tmp_Customer', N'Customer', 'OBJECT'
GO
好的,我已经找到答案了。我的 table 有自定义约束,它调用需要 INT 参数的标量函数。
将所有这些函数的参数更改为 BIGINT 即可解决问题。
我正在尝试向列中插入一个数字。列数据类型是 BIGINT,我很确定我的数字没有超过 BIGINT 的最大值,但我仍然得到
Msg 8115, Level 16, State 2, Line 40
Arithmetic overflow error converting expression to data type int.
The statement has been terminated.
我最近 activity 是我将该列的数据类型从 INT 更改为 BIGINT。我认为我的专栏在内部某处仍被定义为 INT。
这是我的脚本。
Insert into Customer(Cust_ID)
Select 2150000000
列 Cust_ID 数据类型在设计器中为 BIGINT。它也是 PRIMARY_KEY,许多 table 引用它。
编辑: 这是一些迁移脚本
DROP TABLE dbo.Customer
GO
EXECUTE sp_rename N'dbo.Tmp_Customer', N'Customer', 'OBJECT'
GO
好的,我已经找到答案了。我的 table 有自定义约束,它调用需要 INT 参数的标量函数。
将所有这些函数的参数更改为 BIGINT 即可解决问题。