Gaurav
Gaurav

Reputation: 915

Post Replication script in SQL Server 2008

I have setup SQL Server 2008 Transactional Replication between 2 databases. Once the replication session is complete, I want to execute a T-SQL script. Is there a configuration to setup Post Replication script or a mechanism to identify replication is complete and I can hook any script after replication is complete? In case we don't have this configuartion, can we use triggers to identify whether a table has been updated completely during replication and hence use trigger to invoke Post Replication script?

Upvotes: 1

Views: 994

Answers (2)

Siva
Siva

Reputation: 2821

Yes, I would suggest to look at data from system tables to verify details of published tables

Which objects in the database are published?

Publish DB

  • SELECT * FROM sysarticles
  • SELECT * FROM syspublications

Distribution DB

  • Use Distribution
  • GO
  • SELECT * FROM distribution..mspublications

SubscriberDB

  • USE SubscriptionDB
  • SELECT * FROM MSsubscriptions
  • SELECT * FROM MSsubscriber_info

Hope it Helps.

Upvotes: 0

SqlACID
SqlACID

Reputation: 4014

Yes, check the @post_snapshot_script parameter of sp_addpublication, or the Properties page of the publication, under Snapshot, you'll find a section for "Run Additional Scripts" with an option for pre- and post scripts.

Upvotes: 1

Related Questions