Sometimes, IDENTITY seeds get messed up, especially after a db restore, so this script comes in handy. It even gives a little report on what the previous value was and what the new values is. For tables that don’t have IDENTITY values, it gives a clean error and skips them. Nice and easy.
exec sp_MSforeachtable @command1 = 'DBCC CHECKIDENT (''?'', RESEED)'
Advertisement
Comments on: "SQL Server Trick: Script to Reseed All Tables" (2)
Thank you very much for this script. Saved me a lot of scripting..
Thank you, first result from Google and the nÂș 1 solution.