Prasanna Kumar J Prasanna Kumar J - 10 months ago 51
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 Source

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)';