Basically I need to reset Identity Increment for all tables to its original. Here I tried some code, but it fails.
http://pastebin.com/KSyvtK5b
Actual code from
To reseed ONLY tables with an identity column you can use the next script.
It also makes use of sp_MSforeachtable
but taking into account the correct tables.
EXEC sp_MSforeachtable '
IF (SELECT COUNT(1)
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = ''BASE TABLE''
AND ''[''+ TABLE_SCHEMA + ''].['' + TABLE_NAME + '']'' = ''?''
AND OBJECTPROPERTY(OBJECT_ID(TABLE_NAME), ''TableHasIdentity'') = 1) > 0
BEGIN
DBCC CHECKIDENT (''?'', RESEED, 1)
END'