Quantcast
Channel: StackExchange Replication Questions
Viewing all articles
Browse latest Browse all 17268

How to reset identity values for all tables in a database from another database

$
0
0

I have established a transactional replication. I have realized the replication resets all identity values to NULL on the subscriber (backup). Sometimes I need to write to the subscriber database, then back it up and restore it in the publisher (primary). The issue is the identity values need to be identical between both databases.

How can I reset (RESEED) the identity values for lets say database ABC from database XYZ?

If I were to reset it without the need of the database XYZ, it would be something like this

USE  [ABC];
EXEC sp_MSForEachTable '
IF OBJECTPROPERTY(object_id(''?''), ''TableHasIdentity'') = 1
DBCC CHECKIDENT (''?'', RESEED)'
GO

Viewing all articles
Browse latest Browse all 17268

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>