Define a self-increment column, use Delete, and then insert the data, the self-increment column is still incremented by the maximum value before deletion; If you use truncate and then insert the data, the self-increment column increments from the beginning
Script one (using delete):
CREATE table #test (codes int identity,valuess int)
Insert into #test (valuess) Select 1
SELECT * FROM #test
----------------
Delete from #test
------------------
Insert into #test (valuess) Select 2
SELECT * FROM #test
drop table #test
Script two (using truncate):
CREATE table #test (codes int identity,valuess int)
Insert into #test (valuess) Select 1
SELECT * FROM #test
-------------------
TRUNCATE TABLE #test
----------------------
Insert into #test (valuess) Select 2
SELECT * FROM #test
drop table #test
SQL Server self-increment and delete truncate DELETE statement relationships