Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to finding gaps in identity values?

Status
Not open for further replies.

VNDN

Programmer
Feb 28, 2003
27
0
0
US
will someone help me for indentifying gaps in identify values when data is removed in SQL 2000. Thanks in advance.DN
 
This gives you IDENTITY values, after which are gaps:

Code:
SELECT T1.Identity_column
	FROM Your_table T1
		LEFT JOIN Your_table T2 ON T2.Identity_column = T1.Identity_column + 1
	WHERE T2.Identity_column IS NULL
	ORDER BY T1.Identity_column


Zhavic


---------------------------------------------------------------
In the 1960s you needed the power of two Comodore64s to get a rocket to the moon. Now you need a machine which is a vast number of times more powerful just to run the most popular GUI.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top