Question

I am using SQL Server 2008 and have transactional replication setup. I need to be able to execute a pre replication script on the publisher and then a post replication script on the subscriber. Is this possible with transactional replication?

I have found this other article on here, but the post script here only gets executed when the snapsnot is delivered to the subscriber.

Was it helpful?

Solution

This will work if you are running the Distribution Agent on a schedule. Edit the Distribution Agent SQL Agent job. Add a step prior to the Run Agent job step to execute a SQL script on the Publisher. Then add a step after the Run Agent job step which executes sp_addscriptexec to post a SQL script to the Subscriber.

I have a post describing sp_addscriptexec in Executing scripts with sp_addscriptexec. I recommend trying this in your test environment prior to deploying to production.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top