Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens to a SQL Server 2005 table with an identity (int) that goes over maxint?

Tags:

sql-server

For example, will SQL Server warn you or does it just die?

like image 536
Michael Pryor Avatar asked Dec 19 '08 00:12

Michael Pryor


1 Answers

SQL Server 2005 will throw the following error when you overflow the IDENTITY column.

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

Your identity column need not be constrained to an INT and indeed can be set to BIGINT if you suspect that INT will not be large enough.

INT (32-bit signed) will go up to 2,147,483,647 and BIGINT (64-bit signed) to 9,223,372,036,854,775,807 (that's 9 quintillion, enough for 1.3 billion id's per person on the planet).

like image 76
joshperry Avatar answered Oct 23 '22 01:10

joshperry