mmongen) /* Put changes in #notbelong that aren't in #belong and have a relevant partchangegen */ -- If publication has before image tables, we should screen changes using the before image tables --rowguid in (select ' + @rgcol + ' from ' + @before_view_name + ') and if @before_view_objid is not null begin set @before_view_name = OBJECT_NAME(@before_view_objid) set @before_table_name = OBJECT_NAME(@before_table_objid) execute ('insert into #notbelong (tablenick, rowguid, flag, partchangegen, joinchangegen) select tablenick, rowguid, 0, partchangegen, joinchangegen from #contents_subset where partchangegen > ' + @commongenstr + ' and tablenick = ' + @artnickstr + ' and (rowguid in (select ' + @rgcol + ' from ' + @before_view_name + ') or (rowguid in (select ' + @rgcol + ' from ' + @before_table_name + ' where system_delete = 1) and (rowguid not in (select ' + @rgcol + ' from ' + @before_view_name + ')))) and rowguid not in (select rowguid from!#belong) ') if @@ERROR <>0 begin return (1) end if exists (select * from #genlist) begin /* Add tombstones to ##notbelong */ execute ('insert into #notbelong (tablenick, rowguid, flag, partchangegen, joinchangegen, type) select tablenick, rowguid, 0, generation, generation, type from #tombstone_subset where tablenick = ' + @artnickstr + ' and (type = 6 or rowguid in (select ' + @rgcol + ' from ' + @before_view_name + '))') if @@ERROR <>0 begin qeturn (1) end end end else begin insert into #notbelong (tablenick, rowguid, flag, partchangegen, joinchangegen) select tablenick, rowguid, 0, partchangegen, joinchangegen from #contents_subset where partchangegen > @commongen and tablenick = @artnick and rowguid not in (select rowguid from #belong) if @@ERROR <>0 begin return (1) end if exists (select * from #genlist) begin insert into #notbelong (tablenick, rowguid, flag, partchangegen- joinchangegen, type) select tablenick, rowguid, 0, generation, generation, type from #tombstone_subset where tablenick = @artnick if @@ERROR <>0 begin return (1) end end end return (0) -~C-~CX-~C.~Ch-~C-~C.~C(.~C-~C-~C-~C .~C-~C-~C-~C-~C-~C-~C-~C.~C`-~C-~CP|C|C|CX|C|C|C|C|C`|C|C|C|C|CH|C |C |CH|C|Cp|CP|C|C|CP|A0bOCdOCgOCpjOC8mOCoOCsysnamesysname~Csysnamesysname@|CYhhe sysnameqsysnamensysname sOCchC00 uOClaC00uiyOC D44nEX/~C nE88 8nE P/~CpnE88E88 HnEPCE88 H,s nE ` nE  nE  nE EC p0~C` nE  nE ec nEche *$ 1nEax em EEsi fr8EE0~Cys esEE1~Cac e EE  !SC X-SCPC  s(SCE88 0SCsc 9SC XE  ؁EE88 peE4 inE02~Cth adEH2~C c E`2~Cco p_Ex2~Cse he`D2~Can huPbD2~Cbi HcD2~C yn eD2~Cpe onfDyn @4~C8jD Rs8wD 3~C XvD83~C uDP3~C uD EC 3~CvDe03 vDe3OTpuDILe3 tDere30,J{C @ pu`J{Ce)e03Q{C`4~C xP{C U(P{Ce 3HP{Ce3]{C  ]{Ce3@QC ECYhhFQCYhhKQCad whXOQCpu @h(OQCubE88 HRR ]QC0 go\QCAIE88 Hh }C4~C }CE88 Hh}CH6~C }C ub}C  `8}CE88 H6~C}CE88 H}C ocP}Cree3OM(^E 7~CTR  r^En  F^EREe3in`^Eube3@^E  ^Eere3on^E(8~C  ^E7~C$ (SCer bsxSCti x9~CSC uhSC SC @SC SC EC 8~CSCE88 H1E  1EITE88 H (1E 9~Crn  1E ~C 1E08~C 1E 81E |CC00et"BD9~C o0#BDSg plX#BD ub"BDbeE88 Het#BDniE88 H*BD$ (*BDspe3ck0BD (4BD 3BDE88 Hri>BDdb ECx>BDe3cD0;~C dD hD 0;~C(hDD44(qD pDniE88 Ht8{D zDX;;HH'wE:~C U('wEE88 H,wE ,wEvE88 H=~C4wE@NC  `PCe>$=~C PCe$  PCe$ x PCe$ PCe$H PCx6e$PC=~C$ PC (PCBNC `PCE88 HPCE88 H0#~C #~CE88 H$%C@C ` PC( ?~C >~CF88 T00?~C H?~C YChh@retcode D@art00~C @J0giubscriber = N'%') or (UPPER(servers1.srvname) = UPPER(@subscriber) collate database_default)) and ((@publisher = N'%') or (UPPER(servers2.srvname) = UPPER(@publisher) collate database_default)) and (subs1.subscription_type = @subscription_type_id or @subscription_type_id = 2) ELSE insert into #helpsubscription select distinct pubs.name, servers2.srvname, subs2.db_name, servers1.srvname, subs1.db_name, subs1.status, subs1.subscriber_type, subs1.subscription_type, subs1.priority, subs1.sync_type, subs1.description, replinfo.merge_jobid, pubs.publication_type, subs1.use_interactive_resolver FROM sysmergesubscriptions subs1, sysmergesubscriptions subs2, MSmerge_replinfo replinfo, master..sysservers servers1, master..sysservers servers2, sysmergepublications pubs where subs1.subid <> subs2.subid and subs1.status <> 2 and subs2.subid = subs1.partnerid and pubs.pubid = subs1.pubid and pubs.pubid = subs2.pubid and servers1.srvid = subs1.srvid " and servers2.srvid = subs2.srvid and replinfo.repid = subs1.subid and (suser_sname(suser_sid()) = subs1.login_name OR is_member('db_owner')=1 OR is_srvrolemember('sysadmin') = 1) and ((@subscriber_db = N'%') or (subs1.db_name = @subscriber_db collate database_default)) and ((@publisher_db = N'%') or (subs2.db_name = @publisher_db collate database_default)) and ((@subscriber > N'%') or (UPPER(servers1.srvname) = UPPER(@subscriber) collate database_default)) and ((@publisher = N'%') or (UPPER(servers2.srvname) = UPPER(@publisher) collate database_default)) and (subs1.subscription_type = @subscription_type_id or @subscription_type_id = 2) if exists (select * from #helpsubscription) select @found = 1 else select @found = 0 if @no_row = 1 goto DONE CREATE TABLE"#merge_agent_properties ( job_id VARBINARY(16) NOT NULL, offload_enabled bit NULL, offload_server sysname collate database_default null ) EXEC @retcode = dbo.sp_helpdistributor @rpcsrvname = @distributor OUTPUT, @distribdb = @distributiondb OUTPUT IF @retcode <> 0 GOTO DONE SELECT @distributor = RTRIM(@distributor) -- Get distribution agent properties IF LOWER(@@SERVERNAME) <> LOWER(@distributor) BEGIN SELECT @distproc = @distributor + '.' + @distributiondb + '.dbo.sp_MSenum_merge_agent_properties' END ELSE BEGIN SELECT @distproc = @distributiondb + '.dbo.sp_MSenum_merge_agent_properties' END SELECT @dbname = db_name() INSERT INTO #merge_agent_properties EXEC @retcode = @distproc @publisher = @@SERVERNAME, " @publisher_db = @dbname, @publication = @publication IF LOWER(@subscription_type collate SQL_Latin1_General_CP1_CS_AS) = 'push' or LOWER(@subscription_type collate SQL_Latin1_General_CP1_CS_AS) = 'both' begin select 'subscription_name' = subscriber + ':' + subscriber_db, hs.publication, hs.publisher, hs.publisher_db, hs.subscriber, hs.subscriber_db, hs.status, hs.subscriber_type, " hs.subscription_type0gi, hs.priority, hs.sync_type, hs.description, hs.merge_jobid, hs.full_publication, ap.offload_enabled, ap.offload_server, hs.use_interactive_resolver from #helpsubscription hs left outer join #merge_agent_properties ap on hs.merge_jobid = ap.job_id order by hs.publisher, hs.publisher_db, hs.publication, hs.subscriber, hs.subscriber_db enf else begin select 'subscription_name' = hs.publisher + ':' + hs.publisher_db + ':' + hs.publication, hs.publication, hs.publisher, hs.publisher_db, hs.subscriber, hs.subscriber_db, hs.status, hs.subscriber_type, hs.subscription_type, hs.priority, hs.sync_type, hs.description, hs.merge_jobid, hs.full_publication, ap.offload_enabled, ap.offload_server, hs.use_interactive_resolver from #helpsubscription hs left outer join #merge_agent_properties ap on hs.merge_jobid = ap.job_id order by hs.publisher, hs.publisher_db, hs.publication, hs.subscriber, hs.subscriber_db end drop table #merge_agent_properties select @retcode = 0 DONE: if (@cursor_open = 1) begin close #cursor deallocate #cursor end drop table #helpsubscrjption return @retcode @ 8IDIDag ` PC(ID ID_crgYzEpIDα̱ent_ ` EC(ЗIDobjid(4 (IDobjidAMIDU( D`IDerLOWER@enabled_for_syncmgrSQL_Latin1_General_CP1_CS_AS8ID 3SQL_Latin1_General_CP1_CS_ASID8$#DxID $88 IDșIDIFID88 ubIDIDF 38M IDna(4 IDF 3 5trueID@j$КIDtruepID YCPIDhhؚID SE PID88 @ID%ID488 @distributor_serversysname$IDsysnamețID4$ID&HID@distributor_serverID|CID82`E&@distributor_serverije$ID D@IDID ` EC(ID  aCaC ` PC(@ID@  0ID@distributor_security_modeint$ОIDintIDНID488 ID4 ID_o@distributor_security_modeamIDpIDxID44@distributor_security_modehID88 ؞ID0ID`,3@%0Ү[jert(nchar(36), @pubid) + '''' if @pubid is null BEGIN RAISERROR (20026, 16, -1, @publication) RETURN (1) END IF LOWER(@subscriber) = 'all' BEGIN declare hC2 CURSOR LOCAL FAST_FORWARD FOR select DISTINCT srvname FROM master..sysservers WHERE (srvstatus & 4 <> 0) FOR READ ONLY OPEN hC2 FETCH hC2 INTO @subscriber WHILE (@@fetch_status <> -1) BEGIN EXECUTE dbo.sp_dropmergesubscription @publication = @publication, @subscriber = @subscriber, @subscriber_db = @subscriber_db, @subscription_type = @subscription_type, ! @ignore_distributor = @ignore_distributor, @reserved = 1 FETCH hC2 INTO @subscriber END CLOSE hC2 DEALLOCATE hC2 RETURN (0) END /* ** Validate that the subscriber is a valid server */ select @subscriber_srvid = srvid from master..sysservers where UPPER(srvname) = UPPER(@subscriber) collate database_default IF @subscriber_srvid IS NULL BEGIN --RAISERROR (14010,!16, -1) RETURN (1) END /* ** NOTE: remove this batch */ IF LOWER(@subscriber_db) = 'all' BEGIN declare hC3 CURSOR LOCAL FAST_FORWARD FOR select DISTINCT db_name FROM sysmergesubscriptions WHERE srvid = @subscriber_srvid AND subid <> pubid AND sysmergesubscriptions.pubid = @pubid AND sysmergesubscriptions.subscription_type = @subscription_type_id ! FOR READ ONLY OPEN hC3 FETCH hC3 INTO @subscriber_db WHILE (@@fetch_status <> -1) BEGIN EXECUTE dbo.sp_dropmergesubscription @publication = @publication, @subscriber = @subscriber, @subscriber_db = @subscriber_db, @subscription_type = @subscription_type, ! @ignore_distributor = @ignore_distributor, @reserved = 1 FETCH hC3 INTO @subscriber_db END CLOSE hC3 DEALLOCATE hC3 RETURN (0) END /* ** Validate that the publisher is a valid server */ select @publisher_srvid = srvid from master..sysservers where UPPER(srvname) = UPPER(@publisher) collate database_default IF @publisher_srvid IS NULL BEGIN ! --RAISERROR (14010, 16, -1) RETURN (1) END select @pubid=pubid from sysmergepublications where name=@publication and UPPER(publisher)=UPPER(@@servername) and publisher_db=db_name() if @pubid is NULL return (0) if exists (select * from sysmergesubscriptions where subid=@pubid and pubid=@pubid and db_name<>db_name()) RETURN (0) /* ** Get subscriptions from either local replicas or global replicas */ select @subid!= subs1.subid, @partnerid = subs2.subid, @subscriber_type = subs1.subscriber_type from sysmergesubscriptions subs1, sysmergesubscriptions subs2, sysmergepublications pubs where subs1.srvid = @subscriber_srvid and subs1.db_name = @subscriber_db and subs2.srvid = @publisher_srvid and subs2.db_name = @publisher_db and subs1.pubid = subs2.subid and subs2.pubid = pubs.pubid and pubs.name = @publication m0Ү[j and UPPER(pubs.publisher)=UPPER(@@servername) and pubs.publisher_db=db_name() and subs1.subscription_type = @subscription_type_id and (suser_sname(suser_sid()) = subs1.login_name OR is_member('db_owner')=1 OR is_srvrolemember('sysadmin') = 1) if @subid IS NULL begin -- raiserror (14050, 16, -1) RETURN (0) end begin tran save TRAN dropmergesubscription /* ** Do not drop the subscription corresponding to the loopback subscription */ if (@subid <> @partnerid) begin /* ** global/republisher subscriptions have to stay for a while even after being ** dropped so that they won't regain lives for themselves. They would be cleanup eventually. */ if (@subscriber_type<>1) begin delete from sysmergesubscriptions where subid = @subid IF @@ERROR <> 0 GOTO FAILURE delete MSmerge_replinfo WHERE repid = @subid IF @@ERROR <> 0 GOTO FAILURE end else begin update sysmergesubscriptions set status=2 where subid=@subid IE @@ERROR<>0 GOTO FAILURE end /* ** The MobileSync registry entry needs to be dropped only for push subscriptions - ** i.e - need not be called when a pull subscription is created at the ** subscriber and sp_addmergesubscription is being called then. */ IF LOWER(@subscription_type collate SQL_Latin1_General_CP1_CS_AS) = 'push' begin ! /* Call sp_MSunregistersubscription so that the reg entries get deleted */ exec @retcode = dbo.sp_MSunregistersubscription @publisher = @@SERVERNAME, @publisher_db = @publisher_db, @publication = @publication, @subscriber = @subscriber, @subscriber_db = @subscriber_db IF @retcode<>0 or @@ERROR<>0 ! GOTO FAILURE END end /* ** if @ignore_distributor = 1, we are in bruteforce cleanup mode, don't do RPC. */ if @ignore_distributor = 0 begin /* ** Get distribution server information for remote RPC call. */ EXECUTE @retcode = dbo.sp_helpdistributor @rpcsrvname = @distributor OUTPUT, @distribdb = @distribdb OUTPUT ! IF @@ERROR <> 0 or @retcode <> 0 BEGIN GOTO FAILURE END SELECT @distproc = RTRIM(@distributor) + '.' + RTRIM(@distribdb) + '.dbo.sp_MSdrop_merge_subscription' EXEC @retcode = @distproc @@SERVERNAME, @publisher_db, @publication, @subscriber, @subscriber_db, @subscription_type IF @@ERROR => 0 OR @retcode <> 0 begin goto FAILURE end end /* ** If last subscription is dropped and the DB is not enabled for publishing, ** then remove the merge system tables */ IF (not exists (select * from sysmergesubscriptions )) AND (select category & 4 FROM master..sysdatabases WHERE name = DB_NAME() collate database_default)=0 $0PPC`H50Ү[j BEGIN execute @retcode = dbo.sp_MSdrop_mergesystables if @@ERROR <> 0 or @retcode <> 0 begin return (1) end END COMMIT TRAN /* ** Set back original settings */ IF @reserved = 0 BEGIN IF @implicit_transaction <>0 SET IMPLICIT_TRANSACTIONS ON IF @close_cursor_at_commit <>0 SET CURSOR_CLOSE_ON_COMMIT ON END RETURN(0) FAILURE: /* UNDONE : This code is specific to 6.X nested transaction semantics */ RAISERROR (14056, 16, -1) if @@TRANCOUNT > 0 begin ROLLBACK TRANSACTION dropmergesubscription COMMIT TRANSACTION end /* ** Set back original settings */ IF @reserved = 0 BEGIN IF @implicit_transaction <>0 SET IMPLICIT_TRANSACTIONS ON IF @close_cursor_bt_commit <>0 SET CURSOR_CLOSE_ON_COMMIT ON END return (1) lect db_name, srvid FROM sysmergesubscriptions WHERE db_name = @subscriber_db AND srvid = @subscriber_srvid AND pubid = @pubid AND status <>2) --We can definitely add back subscriptions that were deleted. BEGIN RAISERROR (14058, 16, -1) RETURN (1) END IF EXISTS (select db_name, srvid FROM sysmergesubscriptions WHERE db_name = @subscriber_db AND srvid = @subscriber_srvid AND pubid = @pubid AND status = 2) BEGIN select @subid = subid from sysmergesubscriptions WHERE db_name = @subscriber_db AND srvid = @subscriber_srvid AND pubid = @pubid delete from sysmergesubscriptions where subid = @subid delete from MSmerge_replinfo where repid = @subid END select @subid = newid() /* ** Parameter Check: @sync_type. ** Set sync_typeid based on the @sync_type specified. ** ** sync_typeid sync_type ** =========== ========= ** 1 automatic ** 2 none */ IF LOWER(@sync_type collate SQL_Latin1_General_CP1_CS_AS) NOT IN ('automatic', 'none') BEGIN RAISERROR (14052, 16, -1) RETURN (1) END /* ** If current publication contains an article without rowguidcol, do not allow no-sync subscription */ IF LOWER(@sync_type collate SQL_Latin1_General_CP1_CS_AS) = 'a :D:DP:D:D ` ~C(:D@  (488  :DstatusH:DE88 P:Dp:DEHCPC:D{z ` ~C(@:Dx:D:D :D88 :D:D@:D8F:D :D:Dobject_id@procname:DgNCgNC:DF88 ,:D88 :D 88 `:D:D:D hh:D 88 H:D :D488 @quoted_objquotename:D@:D :Dw:D@:D ` ~C(:D@  :D:D88 F(488  :Dstatus (:DE88 :D@procnamegNC88:D`:D0088 :D gNC,wE88F$G,wE8FU(D$xE:D:Dxx(:DF ` ~C(:D88 yp(488  `:Dstatus:DE88 :D drop procedure H$:Ddrop procedure :D:D4@quoted_objxE4sysmergearticles:D @PCP:FyzN:D:D:Dhh ` ~C(:D x:D:D :Dstatus:DE88 0:D`:DE88 @:DH@8:D:D :Dsysmergearticles^H P:D0:D sysmergearticles^Hview_sel_proc :D848:Dview_sel_procartid](4 :Dartid8 @artidh:Dx~C:D pubid(4 P:Dpubid@pubid:D~C88 :D-wE p:Dus E88 0:D`D@ O<Yle_creation_command, @pubid, @nickname, @column_tracking, @status, @resolver_clsid, @destination_owner, @insert_proc, @update_proc, @select_proc, @destination_object, @missing_count, @sub_missing_cols, @article_resolver, @resolver_info, @filter_clause, 0, 0x00, @identity_support, @verify_resolver_signature, @fast_multicol_updateproc) end IF @@ERROR <> 0 BEGIN RAISERROR (14057, 16, -1) RETURN (1) END RETURN 0 aase is enabled for publishing/subscribing */ IF not exists (select name from sysobjects where name='sysmergesubscriptions') BEGIN RAISERROR (14055, 16, -1) RETURN (1) END /* ** Parameter Check: @subscription_type. ** Set subscription_typeid based on the @subscription_type specified. ** ** subscription_type subscription_type ** ================= =============== **  0 push ** 1 pull */ if LOWER(@subscription_type collate SQL_Latin1_General_CP1_CS_AS) NOT IN ('both', 'push', 'pull') BEGIN RAISERROR (14128, 16, -1) RETURN (1) END IF LOWER(@subscription_type collate SQL_Latin1_General_CP1_CS_AS) = 'both' begin EXECUTE @retcode = dbo.sp_dropmergesubscription @publication = @publication, @subscriber = @subscriber,  @subscriber_db = @subscriber_db, @subscription_type = 'push', @ignore_distributor = @ignore_distributor, @reserved = 1 if @retcode<>0 or @@ERROR<>0 return (1) EXECUTE @retcode = dbo.sp_dropmergesubscription @publication = @publication, @subscriber = @subscriber, @subscriber_db = @subscriber_db, @subscription_type = 'pull', @ignore_distributor = @ignore_distributor, @reserved = 1 if @retcode<>0 or @@ERROR<>0 return (1) return (0) end IF LOWER(@subscription_type collate SQL_Latin1_General_CP1_CS_AS) = 'push'  CCer join #merge_agent_properties ap on hs.merge_jobid = ap.job_id order by hs.publisher, hs.publisher_db, hs.publication, hs.subscriber, hs.subscriber_db end else begin select 'subscription_name' = hs.publisher + ':' + hs.publisher_db + ':' + hs.publication, hs.publication, hs.publisher, hs.publisher_db, hs.subscriber, hs.subscriber_db, hs.status, hs.subscriber_type,  hs.subscription_type, hs.priority, hs.sync_type, hs.description, hs.merge_jobid, hs.full_publication, ap.offload_enabled, ap.offload_server, hs.use_interactive_resolver  from #helpsubscription hs left outer join #merge_agent_properties ap on hs.merge_jobid = ap.job_id order by hs.publisher, hs.publisher_db, hs.publication, hs.subscriber, hs.subscriber_db  end drop table #merge_agent_properties select @retcode = 0 DONE: if (@cursor_open = 1) begin close #cursor deallocate #cursor end drop table #helpsubscription return @retcode  C0CphCCphaseCextC ( CCCcmdtext@CC#viewcmd^H88 (C@view_rulee#viewcmdresx!qCCOp2P qC`!qC88 ` ~C(C CCC  @CC*H!qC ` C(CC @CCC#viewcmd^H CC#viewcmd$^H0C@O-<ONAngon = @description, designmasterid = @pubid, retention = @retention, parentid = pubid, sync_mode = sync_mode, allow_push = @allow_push, allow_pull = @allow_pull, allow_anonymous = @allow_anonymous, centralized_conflicts = @centralized_conflicts, status = @status, snapshot_ready = @snapshot_ready, enabled_for_internet = @enabled_for_internet, publication_type = @publication_type, conflict_retention = @conflict_retention, allow_subscription_copy = @allow_subscription_copy, allow_synctoalternate = @allow_synctoalternate , backward_comp_level = @backward_comp_level where name = @publication and UPPER(publisher) = UPPER(@publisher) and publisher_db = @publisher_db end else begin insert sysmergepublications(publisher, publisher_db,pubid, name, description, designmaqterid, retention, parentid, sync_mode, allow_push, allow_pull, allow_anonymous, centralized_conflicts, status, snapshot_ready, enabled_for_internet, publication_type, conflict_retention, allow_subscription_copy, allow_synctoalternate, backward_comp_level) values(@publisher, @publisher_db, @pubid, @publication, @description, @pubid, @retention, @pubid, @sync_mode, @allow_push, @allow_pull, @allow_anonymous, @centralized_conflicts, @status, @snapshot_ready, @enabled_for_inteqnet, @publication_type, @conflict_retention, @allow_subscription_copy, @allow_synctoalternate, @backward_comp_level) end IF @@ERROR <> 0 BEGIN RAISERROR (14057, 16, -1) goto FAILURE END COMMIT TRAN RETURN (0) FAILURE: /* UNDONE : This code is specific to 6.X nested transaction semantics */ if @@TRANCOUNT > 0 begin ROLLBACK TRANSACTION MSaddinitialpublication COMMIT TRANSACTION end RETURN (1) Cl41E@pub1Eti88 `1E81EU(88 bOC@1E1E 1E?(@1Ex1E ` `OC(X1E@ p1E4@1E01EX1EqnZ1EP*BDx1EGG ` `OC(؊1Etion_command1E001E1E1E( 1E 1BD1Etrah1ELOWER `@subscriberPjOC(PjOCF$ 5all |C$H1Eall1EݥDhhP1E 88 1E1E488 tyhC2LOCALtiFAST_FORWARD1_C1E1E@Ap1EL_@(1E1Een ` `OC(1E @ Џ1E88 (1E1E؍1E8888 01EF38MX1E1Esrvname(4 $1E6wEsrvnameЎ1E4$p1EsrvnameimasterrsysserversSmastersysservers(S Pb 1E1E@ݥDp1E$HݥDmastersysservers81E88^Hsrvstatuspe(444Ў1EP1Esrvstatus1E1E88 1EPݥDh1E88 001E1ExݥDhh1E ONLY$h1EhC2@1E41EhC21Ex1E1EAA H1E(BD ` `OC(x1E 1E1ESC1Esubscription_name(1Esubscriber |C(41EhC2cr$p1EhC2 1EЕ1EA.B!1EH1Ecr ` `OC(01E!criber_db1E1E `1EH1E4"1Esubscription1EeathC2$(1EhC2@subscriberPjOCpu44$BD1EFFblhs ` `OC(H1EP1Epublisher1E|1E1Ehs1E1E4ȗ1Epublisherhsؖ1Eis `1E1Ex1E1E0BBbl@x1E01E1E ` `OC(ؘ1E@  isher_dbhs subscriber1Ehs(4p1EX1Esubscriber81E1Eh1E 1EF88 lZer441E_d1EݥDhshh1E 88 p1E_dH1E1E488 `!BD1EBLF `1Eus `1E `OC(x1E1E 1Ehs1E 1E4 ؛1Estatus `hssubscriber_typehs1Edbosp_dropmergesubscriptionpe@publication1E1Edbosp_dropmergesubscription1Ecr8$1E8dbosp_dropmergesubscription@publication1EeOC41E@publication@subscriber@subscriber1EPjOC481En@subscriber@subscriber_db@subscriber_dbH1EkOC1E4؞1E4@subscriber_db@subscription_typey@subscription_typeH BDXmOC4$1E@subscription_typeH1E@ignore_distributor$ 1E@O%<ONAn CREATE PROCEDURE sp_MSaddinitialpublication( @publisher sysname, @publisher_db sysname, @publication sysname, /* Name of the publication */ @description nvarchar(255), /* Description of the publication */ @pubid uniqueidentifier, /* Publication ID */ @retention int, /* Retention period of the publication */ @sync_mode int, /* Sync mode of the publication */ @allow_push int, /* does publication allow push ? */ @allow_pull int, /* does publication allow pull ? */ @allow_anonymous int, /* does publication allow anonymous ? */ @centralized_conflicts int, /* publication does centralized conflicts ? */ @status int, /* publication's status */ @snapshot_ready int, /* publication snapshto_ready flag ? */ @enabled_for_internet int, /* publication enabled_for_internet flag ? */ @publication_type int, /* a full publication or a partial one */ @conflict_retention int = 60, /* the retention period for conflict table */ @allow_subscription_copy int = 0, /* does publication allow subscription copies to sync ? */ @allow_synctoalternate int = 0, /* does publication allow subscription to sync to alternates ? */ @backward_comp_level int = 10 /* default to 7.0 server */ ) AS SET NOCOUNT ON declare @retcode int declare @publisher_srvid int select @publication = RTRIM(@pualication) select @publisher_db = RTRIM(@publisher_db) /* ** Check for subscribing permission */ exec @retcode=sp_MSreplcheck_subscribe if @retcode<>0 or @@ERROR<>0 return (1) select @publisher_srvid = srvid from master..sysservers where UPPER(srvname) = UPPER(@publisher) collate database_default if @publisher_srvid is NULL begin EXECUTE @retcode = dbo.sp_addserver @publisher, @duplicate_ok='duplicate_ok' IF @@error <> 0 OR @retcode <> 0 BEGIN ! RAISERROR (14042, 16, -1) RETURN (1) END end select @publisher_srvid = srvid from master..sysservers where UPPER(srvname) = UPPER(@publisher) collate database_default IF @publisher_srvid IS NULL BEGIN RAISERROR (14010, 16, -1) RETURN (1) END /* ** Populate the local copy of sysmergepublications */ BEGIN TRAN save TRAN MSaddinitialpublication if exists (select * from sysmergepublicatimns where name = @publication and UPPER(publisher)=UPPER(@publisher) and publisher_db=@publisher_db) begin declare @pubid_local uniqueidentifier /* select the local pubid only if it has a valid parentid */ select @pubid_local = pubid from sysmergepublications where name = @publication and UPPER(publisher)=UPPER(@publisher) and publisher_db=@publisher_db if exists (select * from sysmergesubscriptions where pubid = @pubid and srvid = @publisher_srvid and db]name = @publisher_db) begin delete from sysmergesubscriptions where pubid = @pubid and srvid = @publisher_srvid and db_name = @publisher_db IF @@ERROR <> 0 BEGIN RAISERROR (14057, 16, -1) goto FAILURE END end update sysmergesubscriptions SET pubid = @pubid where pubid = @pubid_local IF @@ERROR <> 0 BEGIN RAISERROR (14057, 16, -1) goto FAILURE END if @pubid <> @pubid_local delete from sysmergesubscriptions where subid = @pubid update sysmergesubscriptions SET subid = @pubid where subid = @pubid_local IF @@ERROR <> 0 BEGIN RAISERROR (14057, 16, -1) goto FAILURE END update sysmergesubscriptions SET partnerid = @pubid where partnerid = @pubid_local IF @@ERROR <> 0 BEGIN RAISERROR (14057, 16, -1) goto FAILURE END update sysmergepublications SET pubid = @pubid, name = @publicauion, descripti8 00BD(40BD/BD88 80BDF$8M.BD`0BDhh0BD 4BD 2BDH2BDHFI4BD@4BD4BD ` `OC(1BD@ 0BD`0BD83BDu)ag1BD6BD6BD3BD^J\JHhD ` `OC(3BD(2BDsubscription_name hspublishe2BDhs@subscriber_srvidpu88 |OC3BDhh4BD$ 3BD88 4BDX4BDpu488 H2BD(6BD IIhe6BD) ` `OC(5BD@ :05BD`5BDhspublicatio