Prasanna Kumar J Prasanna Kumar J - 1 month ago 7
SQL Question

How to reset autoincrement id of all tables in a database using SQL Server 2008?

I use the command

DBCC checkident ('tablename', reseed, 200000000);


but I have over 150 tables...

Answer

You can use undocumented feature sp_MSforeachtable http://weblogs.sqlteam.com/joew/archive/2007/10/23/60383.aspx

EXECUTE sp_MSforeachtable 'DBCC checkident ([?], reseed, 200000000)';