Jun 25, 2003 #1 M 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.
hi, How can finde missing number in identity column and insert particular missing number programmaticaly in SQL Server 2000.
Jun 25, 2003 #2 Derek Stone Exalted One Joined Nov 17, 2002 Messages 1,878 Location Rhode Island User Rank *Expert* 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.
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.