/ Published in: SQL
Re-seed identity table if rows were deleted/there are gaps in numerical order
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
DECLARE @TableName VARCHAR(255) DECLARE @MaxID INT SET @TableName = 'Categories' SELECT @MaxID = MAX(category_id) FROM categories DBCC CHECKIDENT(@TableName, RESEED, @MaxID) GO