📜  重置表的标识列并删除测试记录 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:11.685000             🧑  作者: Mango

代码示例1
-- 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)