So here is the normal code if I want to reset all tables to 1
exec sp_MSforeachtable @command1 = 'DBCC CHECKIDENT(''?'', RESEED, 1)'
what if i want to reset it to the max ID number that is there in my Table i mean something like that
exec sp_MSforeachtable @command1 = 'DBCC CHECKIDENT (''?'', RESEED, (select IDENT_CURREN(''?'') )'
anyone can explain why it doesn't work ? thanks
the purpose of doing this is , sometimes when the server shuts down , the identity column just jumps from its value by 1000 for example if the current identity value is 2 and the server shuts down , next value would be 1002