Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What will append if the maximum value of an identity column is reached? [duplicate]

Tags:

sql-server

Possible Duplicate:
What happens to the primary key Id? when it goes over the limit?

what will append if have an SQL server table with an identity column (says an int) that reaches the maximal capacity of the int ?

Go back to the beginning ?

Assume that the lines grow 100 by 100. Each time I insert 100 new lines, I delete the 100 old ones.

Thanks for your answer Best regards

like image 573
Tim Avatar asked Oct 06 '11 12:10

Tim


People also ask

What happens when identity column reaches max?

Each time a row is inserted into the table, the identity column is assigned the next highest value. If the identity reaches the maximum value, inserts will fail.

Can identity column have duplicate value in SQL Server?

SQL Server internally manages the values of Identity Columns and does not generate any Duplicate Values.

What is the max of identity value?

The maximum value that you can insert into an IDENTITY column is 10 precision - 1.

Can we specify maximum value for a identity property?

The maximum value will be the largest value that a type can support. Suppose you are using an Int type as IDENTITY, in 32 bit system the max number will be 2^32-1. When this number is reached, the next attempt to insert a value will result in a overflow error and will fail.


2 Answers

You'll get an arithmetic overflow error when you exceed the max int value.

Try it:

DECLARE @t TABLE (
    id INT IDENTITY (2147483647,1), 
    name VARCHAR(100)
)


INSERT INTO @t (name) VALUES ('Joe')  
INSERT INTO @t (name) VALUES ('Tim')
like image 138
Joe Stefanelli Avatar answered Dec 26 '22 17:12

Joe Stefanelli


It won't allow you to insert more rows.

like image 43
Icarus Avatar answered Dec 26 '22 19:12

Icarus