Answers for "Reset a table's identity column and remove test records"

SQL
0

Reset a table's identity column and remove test records

-- Delete Record From table
DELETE FROM tbl_emp
WHERE id >= 4 ;

DECLARE @NewSeed NUMERIC(10)

-- Get the Last Value from the Table from where
-- You want to restore the Identity Column Value
SELECT @NewSeed = MAX(id)
FROM tbl_emp ;

-- RESEED the IDENTITY column Value
DBCC CHECKIDENT (tbl_emp, RESEED, @NewSeed)
Posted by: Guest on December-29-2021

Code answers related to "Reset a table's identity column and remove test records"

Code answers related to "SQL"

Browse Popular Code Answers by Language