identity number

m_nathani

Member
Joined
Apr 15, 2003
Messages
11
Location
india
hi,

How can finde missing number in identity column and insert particular missing number programmaticaly in SQL Server 2000.
 
I cant think of a single reason as to why one would need to do that. Nevertheless...
Code:
SELECT id FROM table
Then loop through the returned records to find the "missing" rows. For each missing row execute the following T-SQL:
Code:
SET IDENTITY_INSERT dbo.tablename ON
GO
INSERT (id) VALUES (<identity>) INTO dbo.tablename
GO
... replacing "<identity>" with the one just found.
 
Back
Top