Groups | Blog | Home
all groups > sql server replication > april 2006 >

sql server replication : Fire triggers when reinitializing



John HÃ¥rd
4/7/2006 8:44:02 AM
Hello,

I have a transactional replication set up and I want a trigger on the
destination table to fire on all every row when I reinitialize the
replication. How do I make this happen? Right now the trigger won't fire
during the initial load of data, but after that it works fine.
Is there a setting somewhere?

I am using SQL server 2005 on both the subscriber and publisher.

Thanks,
Raymond Mak [MSFT]
4/7/2006 11:21:59 AM
Hi John, the setting to enable firing of triggers during the initial bulk
load is not exposed in SSMS, but it is configurable through the
@fire_triggers_on_snapshot parameter in sp_addarticle and the
'fire_triggers_on_snapshot' property through sp_change_article.

-Raymond

[quoted text, click to view]

Paul Ibison
4/7/2006 5:41:21 PM
John,
I've never tested this, but presumably the initial load is a bulk insert
with FIRE_TRIGGERS set to false, that is assuming your triggers aren't
marked as NFR and there aren't any arguments on the snapshot or distribution
agents to control this setting. In this case you could try issuing
sp_addtabletocontents after the load, or use sp_addscriptexec to initiate
running the code that the trigger currently runs.
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)

Paul Ibison
4/8/2006 8:42:15 PM
Thanks Raymond,
sorry - missed the SQL Server 2005 bit :)
Rgds,
Paul Ibison

John HÃ¥rd
4/9/2006 11:39:01 PM
Thanks a lot guys. After setting 'fire_triggers_on_snapshot' to 'true', it
now works like a charm.

/John HÃ¥rd

[quoted text, click to view]
AddThis Social Bookmark Button