What happens when my integer IDENTITY runs out of scope?

          

Interview questions

SQL Server - integer IDENTITY runs out of scope

Next>>         SQL Server tutorial  

SQL Server - integer IDENTITY runs out of scope - Feb 27, 2010 at 11:50 AM by Shuchi Gauri

What happens when my integer IDENTITY runs out of scope?

SQL Server does not start all over again or try to fill the existing gaps in the sequence if IDENTITY runs out of scope. The user needs to explicitly handle such a situation. One solution is to alter the data type of the column to BIGINT or DECIMAL(38,0)

SQL Server - integer IDENTITY runs out of scope - May 05, 2009 at 22:00 PM by Rajmeet Ghai

What happens when my integer IDENTITY runs out of scope?

An integer data type can have a variety of IDENTITY values like int, bigint, tinyint etc.

To avoid the integer IDENTITY to run out of scope, BIGINT should be used as the data type or DECIMAL (38,0)

CREATE TABLE sample_t ( col1 BIGINT IDENTITY(-9223372036854775808, 1) )

SQL Server - integer IDENTITY runs out of scope - June 21, 2009 at 09:00 AM by Amit Satpute

What happens when my integer IDENTITY runs out of scope?

The range you get when the IDENTITY property on columns of the INT data type and on DECIMAL with scale 0 are defined is:

TINYINT                0 – 255
SMALLINT           -32.768 – 32.767
INT                        -2.147.483.648 - 2.147.483.647
BIGINT                 -2^63 - 2^63-1
DECIMAL             -10^38 to 10^38-1

When an INTEGER IDENTITY value is about to run out of scope an Arithmetic overflow error converting IDENTITY to data type int. is thrown.

EXAMPLE:
CREATE TABLE XYZ (col1 INT IDENTITY(2147483647,1))
GO
INSERT INTO XYZ DEFAULT VALUES INSERT INTO XYZ DEFAULT VALUES SELECT * FROM XYZ
DROP TABLE XYZ

Result:

(1 row(s) affected) Server: Msg 8115, Level 16, State 1, Line 2 Arithmetic overflow error converting IDENTITY to data type int. Arithmetic overflow occurred.

Next>>

Also read

Define Identity and uniqueidentifier property of Column.

Answer - Column with identity property contains unique system generated value in the table. Column with identity property is similar to AutoNumber field in MS Access....

What happens when my integer IDENTITY runs out of scope?

An integer data type can have a variety of IDENTITY values like int, bigint, tinyint etc. .........

What are the lock types?

Answer - Shared Lock allows simultaneous access of record by multiple Select statements. Shared Lock blocks record from updating and will remain in queue waiting while record is accessed for reading......

Define database objects.

Answer - SQL Server database stores information in a two dimensional objects of rows and columns called table......



Write your comment - Share Knowledge and Experience


 

 
Latest placement tests
Latest links
 
Latest MCQs
» General awareness - Banking » ASP.NET » PL/SQL » Mechanical Engineering
» IAS Prelims GS » Java » Programming Language » Electrical Engineering
» English » C++ » Software Engineering » Electronic Engineering
» Quantitative Aptitude » Oracle » English » Finance
Home | About us | Sitemap | Contact us | We are hiring