Quantcast
Channel: SQL Server Replication forum
Viewing all articles
Browse latest Browse all 4054

SQL Server merge replication copy data from production database to test database

$
0
0

Current setup: SQL Server 2016 merge replication with 1 publisher and 1 subscriber. Same exact setup for our test environment.  We currently are setup with simple recover model and do 4 full database backups each day. Size of the database is around 5.1 GB.

Goal: I would like to restore data from production server to test server and ideally have option to select all tables or a subset of the tables.

Things I have tried: I have done a drop subscription and restore database, but rather not go through the whole process of re setting up the merge replication environment every time. Such as re-adding SQL Objects that exist on subscriber only to re adding users, to re-adding encryption keys etc.

I then tried SSMS database task – Import data. (I tested with one table) I created the package and then added a SQL Server Agent job to run the .DTSX package. The data copied from production publisher to test publisher, but the data did not replicate to the test subscriber. 

I then tried to delete the data from test publisher and got the following error

Cannot insert duplicate key row in object 'dbo.MSmerge_tombstone' with unique index 'uc1MSmerge_tombstone'. The duplicate key value is (99999999, 99999-…..).

After researching the above error, it appears I should not do a restore with Keep_Replication true, I did not get an option to set that to false. I also did not see an option to view the script so I could possibly modify that setting?  I looked during the process of creating the package and used SSDT to view the package details.

I ended up dropping the table from the publication, deleted the data and then re adding the table to the publication.

I spent a lot of time researching this but was unable to find a solution to copy data from production to test for those who have merge replication setup and just want to copy data and not the SQL objects from production to a test environment.



Toni


Viewing all articles
Browse latest Browse all 4054

Trending Articles



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