SQL Server算术溢出错误将IDENTITY转换为数据类型int但尚未达到int的最大值

时间:2022-04-10 16:08:50

I'm working with a table that has a PK with data type INT. The column has "Identity Increment" is set 1 and "Identity Seed" set to 1.

我正在使用具有数据类型为INT的PK的表。该列的“Identity Increment”设置为1,“Identity Seed”设置为1。

I'm trying to do an insert and getting the following error:

我正在尝试插入并收到以下错误:

Msg 8115, Level 16, State 1, Line 3
Arithmetic overflow error converting IDENTITY to data type int.
Arithmetic overflow occurred.

When I run the following to see what the Max id is I get is 1702747645:

当我运行以下内容以查看Max ID是得到的是1702747645:

SELECT Max(Id) FROM Log_Records

Int is suppose to have a cap of 2,147,483,647, so I'm wondering why I may be getting this error?

Int假设上限为2,147,483,647,所以我想知道为什么我会收到这个错误?

1 个解决方案

#1


3  

Try running DBCC CHECKIDENT('Log_Records', NORESEED);

尝试运行DBCC CHECKIDENT('Log_Records',NORESEED);

This will report the current identity value in the specified table. The next identity value is not necessary sequential with the maximum value in the table, for instance if you have transactions that have rolled back.

这将报告指定表中的当前标识值。下一个标识值不必与表中的最大值一致,例如,如果您有已回滚的事务。

#1


3  

Try running DBCC CHECKIDENT('Log_Records', NORESEED);

尝试运行DBCC CHECKIDENT('Log_Records',NORESEED);

This will report the current identity value in the specified table. The next identity value is not necessary sequential with the maximum value in the table, for instance if you have transactions that have rolled back.

这将报告指定表中的当前标识值。下一个标识值不必与表中的最大值一致,例如,如果您有已回滚的事务。