Michael Pryor
Michael Pryor

Reputation: 25346

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

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

Upvotes: 7

Views: 1037

Answers (2)

joshperry
joshperry

Reputation: 42227

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).

Upvotes: 18

Sam
Sam

Reputation: 7678

It would likely do both.

Upvotes: 0

Related Questions