I have a T-SQL table variable (not a table) which has an auto incrementing identity column. I want to clear all data from this variable and reset the identi
declare @tb table (recid int,lineof int identity(1,1))
insert into @tb(recid)
select recid from tabledata
delete from @tb where lineof>(select min(lineof) from @tb)+@maxlimit
I did this when I wanted to use a TOP and a variable when using SQL 2000. Basically, you add in the records and then look at the minimum one. I had the same problem and noticed this thread. Deleting the table doesn't reset the seed although I imagine using GO should drop the table and variable to reset the seed.
@maxlimit in the query above was to get the top 900 of the query and since the table variable would have a different starting identity key, this would solve that issue.
Any subsequent query can subtract that derived procedure to make it insert as "1", etc.