/*************************************************
SET IDENTITY + RESEED
***************************************************/
DBCC
CHECKIDENT ('[DB].[SCHEMA].[TABLE]', RESEED, 0);
/******
Although most answers are suggesting RESEED to 0, But many a times
we need to just reseed to next Id available
******/
declare @max int
select @max=max([Id])from [TestTable]
if @max IS
NUll //check when max is returned as null
SET @max = 0
DBCC CHECKIDENT ('[TestTable]', RESEED,@max)
No comments:
Post a Comment