i deleted records table on sql server 2014 using truncate function, new records on table begin pk 1.
is there way not reset primary key new records begin last pk + 1?
deleting work. time delete takes can issue. if have truncate can following:
- get maximum value table , store in variable.
- truncate table
- reseed identity variable value + 1.
here example.
declare @maxid int; select @maxid = max(id) + 1 tablea; truncate table tablea; dbcc checkident ('dbo.tablea', reseed, @maxid);
new inserts table continue previous identity value.
marius
Comments
Post a Comment