Transactional Replication sp question

Why in some of the MS generated procs is there a secondary create proc statement I believe it has something to do with primary and foreign keys but it is not consistent accross all tables that have primary keys. I have included the code of one of the procs.

create procedure "sp_MSins_AH_MEMBER_ALERTS" @c1 bigint,@c2 smallint,@c3 bigint,@c4 int,@c5 datetime,@c6 datetime,@c7 bit,@c8 uniqueidentifier

AS
BEGIN


insert into "AH_MEMBER_ALERTS"(
"id", "company", "account", "alert_id", "start_date", "end_date", "clipboard", "rowguid"
)

values (
@c1, @c2, @c3, @c4, @c5, @c6, @c7, @c8
)


END

GO

create procedure "sp_MSins_AH_MEMBER_ALERTS";2 @c1 bigint,@c2 smallint,@c3 bigint,@c4 int,@c5 datetime,@c6 datetime,@c7 bit,@c8 uniqueidentifier
as
if exists ( select * from "AH_MEMBER_ALERTS"
where "id" = @c1
)
begin
update "AH_MEMBER_ALERTS" set "company" = @c2,"account" = @c3,"alert_id" = @c4,"start_date" = @c5,"end_date" = @c6,"clipboard" = @c7,"rowguid" = @c8
where "id" = @c1
end
else
begin
insert into "AH_MEMBER_ALERTS" ( "id","company","account","alert_id","start_date","end_date","clipboard","rowguid" ) values ( @c1,@c2,@c3,@c4,@c5,@c6,@c7,@c8 )
end



Answer this question

Transactional Replication sp question

  • carb

    For the article 'AH_MEMBER_ALERTS', what value did you specify for sp_addarticle parameter @pre_creation_cmd

    It looks like the 2nd proc should be the correct one, but most likely didn't drop the first one because you might have specified to not drop existing object. Can you confirm


  • June Low

    This is an MS created procedure why would it matter To answer your question it is set to @pre_creation_cmd = N'drop'.

    Josh


  • KimballJohnson

    Do you have concurrent snapshot enabled If so, then is the reason. When distribution agent applies snapshot, it will use the 2nd proc, when distribution agent is just replicating commands, it will use the 1st proc. Reason being is that when generating a concurrent snapshot, the table is not locked, so we don't know if an insert that is logged during snapshot generation is included in the snapshot or not.
  • Paul Baudouin

    can you tell me the sql server version of the publisher, distributor and subscriber
  • Meher123

    I know it's an MS proc, but if you didn't specify DROP, there's a chance it would just create a new one along with existing ones. But since you did specify DROP, this isni't the case. let me dig into it some more.
  • jh55557777

    All 2k sp3a.
  • Transactional Replication sp question