c;0??ACGKOSSSSSW[_cذz_# @wr i` pr Z0n exn 5x6x6xr tr l p n Hmaster.mdfcwx &gl &(x Zw`YwMcwj w wi &(x &j &x $(j RC.j RCpl wȰwl l Xw Zw`YwYwx C:\TEMP\templog.ldf&(x  \l yw3 8l < w0wl Lw 3 l Em w wx l @l .3 3 Dp IKx p .ldfogwPp `@1 17P  10 0 4EMGCC?SSSYYC;E9C=AI?AIGOYYOKYUGGGSKE?]YGSGKUKSA=;CEGE0&vM`E@subscriber$0&vM`M@destination_db0&W`G@distributor0&W`C@distribdb0&W`@C@directory0&W`?@account0&W`88 S@min_distretention0&W`88 S@max_distretention0&W`88 S@history_retentiony0&W`Y@history_cleanupagentdec0&W`  Y@distrib_clea@nupagentera0&W`  C@publishert0&W`  ;@locale0&W`  E@rpcsrvname 0&a`9@namenic0&a`xC@subsystemb0&a`=@serverfil0&a`A@usernamexec0&a`@I@databasenamect 0&a`00?@enabled 0&a`88 A@freqtypect 0&a`88 I@freqintervald) 0&a`88  G@freqsubtype0&a`88  O@freqsubinterval0&a`88  Y@freqrelativeinterval0&a`88 @ Y@freqrecurrencefactorpda0&a`88  O@activestartdate 0&a`88 K@activeenddatea0&a`88 Y@activestarttimeofdaybid0&a`88 U@activeendtimeofday0000&a`88 G@nextrundatei0&a`88 @G@nextruntime0&a`88 G@runpriority0&a`S@emailoperatorname0&a`88 K@retryattempts0&a`88 E@retrydelay0&a`@?@command0&a`88 ]@loghistcompletionlevel0&@a`88 Y@emailcompletionlevel0&a`G@description0&a`S@tagadditionalinfo0&a`88 G@tagobjectid0&a`88 K@tagobjecttype0&a`88 U@cmdexecsuccesscode0&a`@K@category_name0&a`hh  S@failure_detection0&a`88 !!A@agent_id0&a`""=@job_id0&gQa$$;@pubid0&gQa88 C@tablenick0&vfaE@table_nameHS0&vfaG@ta@ble_owner<1 60 4x8L1!0vM`P1 040170V04|021C0&gQaC@basetable\1s0$6gQa$@basetableP1@ 0 gQa@]y 1gQa1 V10X0*gQaP 17 Xsp_MScontractsubsnbl1 !I0(46gQa4sp_MScontractsubsnbD1 [0 gQaH/17SplitNextD1  @0/@L11%L11&V4%L1%+1Pd11)0k1a)xpstar.dll<1 11.x8L1*&0k1a@P1  141 171 V01 1{0gQa{ create PROCEDURE sp_MScontractsubsnb (@pubid uniqueidentifier, @tablenick int, @basetable nvarchar(258)) AS declare @filter_clause nvarchar(4000) declare @join_nick int declare @jointable nvarchar(258) declare @filterid int declare @retcode int declare @tablenickstr n@archar(10) set @tablenickstr = convert(nchar(10), @tablenick) /* First, try to remove rows from notbelong based on the article filter, if there is one */ select @filter_clause = subset_filterclause from sysmergearticles where pubid = @pubid and nickname = @tablenick if len(@filter_clause) > 0 begin exec ('delete from #notbelong where tablenick = ' + @tablenickstr + ' and rowguid in (select RowGuidCol from ' + @basetable + ' where ' + @filter_clause + ')' ) end /* Now loop ov@r any join filters that have this as the base_table */ select @filterid = min(join_filterid) from sysmergesubsetfilters where pubid = @pubid and art_nickname = @tablenick while @filterid is not null begin /* Get joining table and filter clause */ select @join_nick = join_nickname, @filter_clause = join_filterclause from sysmergesubsetfilters where pubid = @pubid and join_filterid = @filterid exec @retcode = dbo.sp_MStablenamefromnick @join_nick, @jointable out, @pubid /* Exec q@ery to remove rows from #notbelong that still belong to partial */ exec ('delete from #notbelong where tablenick = ' + @tablenickstr + ' and rowguid in (select ' + @basetable + '.RowGuidCol from ' + @basetable + ', ' + @jointable + ' where (' + @filter_clause + ') and ' + @jointable + '.RowGuidCol not in (select rowguid from #notbelong))') /* Find the next filter that might apply */ select @filterid = min(join_filterid) from sysmergesubsetfilters where pubid = @pubid and art_nHckname = @tablenick and join_filterid > @filterid end nP1  1P1 1P1 1 P1 140170́CV0|,<T|4dhH Pdatasizeiuev X 1 DV11 hT17 user_transaction 1 gQat1 V11  **gQa@daaph X Z(2641 171 (@f0D\= null, /* size of data device in Meg. */ @datalogical4 sysname = null, /* logical name of data device */ @dataphysical4 nX01!@627 grrevzeL1!\ 0gQa P1!  1 41!6271!dV0m0X Meg. */ @datalogical6 sysname = null, /* logical name of data device */ @dataphysical6 nvarchar (260) = null, /* physical name of data device */ @datasize6 int = null, /* size of data device in Meg. */ P,1"D c0(AEb9cX27"sp_MSexpandsubsnb dt1"a0 ;0&Eb$$;@pubidnT1"s16Eb@pubidP1" 1Eb@]y*/ P1" 1"@EbgQaata 1"Eb41"Q0 T0*EbP 27 Tsp_MSexpandsubsnbh1"Y)006Eb0sp_MSexpandsubsnbD1" [1  Eb$1" 7+"0Eb create PROCEDURE sp_MSexpandsu@bsnb (@pubid uniqueidentifier) AS declare @filterid int declare @base_nick int declare @join_nick int declare @basetable nvarchar(258) declare @jointable nvarchar(258) declare @join_clause nvarchar(4000) declare @retcode int declare @base_@nickstr nvarchar(10) /* get first filter to expand on */ select @filterid = min(join_filterid) from sysmergesubsetfilters f, #notbelong nb where pubid = @pubid and nb.tablenick = f.join_nickname and f.join_filterid > nb.flag while @filterid is@ not null begin /* get join clause and tables for this filter */ select @join_nick = join_nickname, @join_clause = join_filterclause, @base_nick = art_nickname from sysmergesubsetfilters where pubid = @pubid and join_filterid = @filterid @ exec @retcode = dbo.sp_MStablenamefromnick @join_nick, @jointable out, @pubid exec @retcode = dbo.sp_MStablenamefromnick @base_nick, @basetable out, @pubid set @base_nickstr = convert(nchar(10), @base_nick) /* Mark rows so that we know we've @expanded those rows for this filter */ update #notbelong set flag = @filterid where flag < @filterid /* exec an insert/select query to expand #notbelong */ exec ('insert into #notbelong (tablenick, rowguid, flag) select ' + @base_nickstr @+ ', ' + @basetable + '.RowGuidCol, 0 from ' + @basetable + ', ' + @jointable + ' where ( ' + @jointable + '.RowGuidCol in (select rowguid from #notbelong) ) and ' + @join_clause) /* if any rows inserted, try to contract the #notbelong tabl@e */ if @@rowcount <> 0 exec @retcode = dbo.sp_MScontractsubsnb @pubid, @base_nick, @basetable /* get next filter to expand with */ select @filterid = min(join_filterid) from sysmergesubsetfilters f, #notbelong nb where pubid = @pubid@ and nb.tablenick = f.join_nickname and f.join_filterid > nb.flag end idP1"  1!P1" 1" P1" 1" P1" 1"41"271"H́CV08t0<|(\ ' + @notbelongsname + ' (tablenick int NOT NULL, rowguid uniqueidentifier NOT NULL, generation int NULL, lineage varbinary(255) NULL, type tinyint NOT NULL) ') if @@ERROR <>0 return (1) create table #temp_cont (temp_id int identity NOT NULL, tablenick int NOT NULL, rowguid uniqueidentifier NOT NULL, partchangegen int null, joinchangegen int null) /* step 2 setup pass through MSmerge_contents */ /* article with permanent views can be hX1-DQ1"T37 user_transaction 1-Ebt1-Q1- **Eb an we TlVhe 41-371-(@f0D\ into #notbelong (tablenick, rowguid, flag, partchangegen, joinchangegen) select tablenick, c.rowguid, 0, partchangegen,X01.@b37 grrev L1.\ 1!Eb P1.  1" 41.b371.dV0&0Xname = view_sel_proc from sysmergearticles where pubid = @pubid and nickname = @artnick /* Get name of rowguidcol. Aliasing doesn't work through a view. */ select @rgcol = name from syscolumns wherP-f,.1/D c1"(A9c0-dT37sp_MSdelsubrowsecx1/a1"?0&9c$$?@rowguidX1/s1" 69c @rowguid|1/a1/C0&9c88 C@tablenick.\@/s1/$69c$@tablenick1/a1/K0&9c00K@metadata_typepd1/s1/,69c,@metadata_type1/a1/G0&9cG@lineage_olde`1/ s1/(69c@(@lineage_old1/ a1/ E0&9c88 E@generationewo`1/ s1/ &69c&@generationin1/ a1/ G0&9cG@lineage_newr`1/ s1/ (69c(@lineage_newt1/a@1/ ;0&9c$$;@pubidrT1/s"1/69c@pubidP1/ , 9c˧inamP1/ 1/9c@]y@roP1/ 1/9clonP1/ 1/9cbelP1/@ 1/9c taP1/ 1/9cf&bKintP1/ 1/9cEb#inP1/ 1/9c=abl 1/9c41/Q 1-P0*9cP 37 Psp_MSdelsubrowsd1/!Y1 @,69c,sp_MSdelsubrowsD1/[1"  9cH/37SplitNextD1/ 1/ @xecL1/8L1/8+ nogsL1/ &8L,nel1/!@1/20!nc2 create procedure sp_isarticlecolbitset @colid int, @colbitmap binary(32) as declare @word tinyint declare @mval int declare @mask smallint select @word = convert(tinyint, 16 - floor((@colid-1)/16)) select @mval = power(2, (@colid-1) % 16 ) select @mask = convert( smallint, convert( binary(2), substring( convert( nchar(2), convert( binary(4), @mval ) ), 2, 1 ) ) ) if convert( binary(2), substring( convert( nchar(16),@colbitmap), @word, 1 )@) & @mask = @mask begin return 1 end else begin return 0 end lo<1/" 81/ 6x8L1/#*.19c('P1/$  1.41/371/V01/1/"09c create PROCEDURE sp_MSdelsubrows (@rowguid uniqueidentifier, @tablenick i@t, @metadata_type tinyint, /* 0 - Missing, 1 - Tombstone, 2 - Contents, 3 - ContentsDeferred */ @lineage_old varbinary(255), @generation int, @lineage_new varbinary(255), @pubid uniqueidentifier = NULL) as set nocount on declare @success int declare @tablename nvarchar(258) declare @rowguidstr nvarchar(40) declare @match int declare @new_metatype tinyint declare @retcode smallint declare @reason nvarchar(255) declare @procname nvarchar(258) declare @ownername @ysname /* ** Check to see if current publication has permission */ exec @retcode=sp_MSreplcheck_connection @tablenick = @tablenick if @retcode<>0 or @@ERROR<>0 return (1) select @success = 0 /* Parameter validation */ if (@rowguid is null) begin RAISERROR(14043, 16, -1, '@rowguid') return (0) end if (@tablenick is null) begin RAISERROR(14043, 16, -1, '@tablenick') return (0) end if @pubid is NULL exec @retcode = dbo.sp_MStablenamefromnick @tablenick, @tablename output else exec @retcode = dbo.sp_MStablenamefromnick @tablenick, @tablename output, @pubid if @@ERROR<>0 return (0) if (@tablename is null) begin RAISERROR(14043, 16, -1, '@tablename') return (0) end if (@lineage_new is null) begin RAISERROR(14043, 16, -1, '@lineage_new') return (0) end if (not exists(select * from sysobjects where name = 'MSmerge_contents')) begin RAISERROR(20054 , 16, -1) return (0) end set @rowguidstr = '''' + convert(nc@ar(36), @rowguid) + '''' -- Are we just changing the type of a tombstone? if (@metadata_type = 5 and exists (select * from MSmerge_tombstone where rowguid = @rowguid and tablenick = @tablenick)) begin set @reason = formatmessage (20563) -- Moved out of partial range update MSmerge_tombstone set type = @metadata_type, reason = @reason where rowguid = @rowguid and tablenick = @tablenick set @success = 1 return @success end -- Are we just changing the type of a tombstone? @f (@metadata_type = 6 and exists (select * from MSmerge_tombstone where rowguid = @rowguid and tablenick = @tablenick)) begin set @reason = formatmessage (20564) -- System deleted update MSmerge_tombstone set type = @metadata_type, reason = @reason where rowguid = @rowguid and tablenick = @tablenick set @success = 1 return @success end -- begin transaction and lock row that we plan to delete begin transaction select @ownername = user_name(uid) from sysobjects where id = @bject_id(@tablename) select @procname = select_proc from sysmergearticles where objid = object_id(@tablename) and pubid = @pubid exec @retcode = @procname @type =8, @rowguid=@rowguid select @success = 2 if @metadata_type = 5 begin set @match = 1 set @new_metatype = 5 end else if @metadata_type = 6 begin set @match = 1 set @new_metatype = 6 end else begin exec @retcode=sp_MScheckmetadatamatch @metadata_type, @rowguid, @tablenick, @lineage_old, @match outpu@ set @new_metatype = 1 end if (@match = 1) begin /* If there are any joinfilters with this as the join table, try to expand to deleting ** a set of related rows. */ if (exists (select * from sysmergesubsetfilters where pubid = @pubid and join_nickname = @tablenick)) begin declare @tn int declare @table_name sysname set @reason = formatmessage (20563) -- Moved out of partial range /* create temp and put in our tablenick, rowguid */ create tabl@ #notbelong (bookmark int identity NOT NULL, tablenick int NOT NULL, rowguid uniqueidentifier NOT NULL, flag int NOT NULL) create index #indnbelong on #notbelong (rowguid) insert into #notbelong (tablenick, rowguid, flag) values (@tablenick, @rowguid, 0) /* call expand proc */ exec @retcode = dbo.>0 H 1/'1/' 09c sp_MSexpandsubsnb @pubid select @tn = max@(tablenick) from #notbelong where flag > -1 while @tn is not null begin exec @retcode = dbo.sp_MStablenamefromnick @tn, @table_name out, @pubid /* delete all rows indicated by the temp table */ exec ('delete from ' + @table_name + '@ where RowGuidCol in (select rowguid from #notbelong)' ) /* change tombstone type for those rows */ update MSmerge_tombstone set type = 5, reason = @reason where tablenick = @tn and rowguid in (select rowguid from #notbelong) @ /* move on to next nickname - decreasing makes delete order correct */ update #notbelong set flag = -1 where tablenick = @tn select @tn = max(tablenick) from #notbelong where flag > -1 end /* drop temp, set success */ dro@p table #notbelong exec dbo.sp_MSsetrowmetadata @tablenick, @rowguid, @generation, @lineage_new, NULL, @new_metatype select @success = 1 end else begin /* ** select_proc makes a delete with @type = 5, despite its name. *@/ exec @retcode = @procname @type =5, @rowguid=@rowguid if (@@error = 0 and @@rowcount = 1) begin exec dbo.sp_MSsetrowmetadata @tablenick, @rowguid, @generation, @lineage_new, NULL, @new_metatype select @success = 1 end @else select @success = 3 end end commit return (@success) P1/(  1/%P1/) 1/)P1/* 1/*  P1/+ 1/+41/371/H * ++8+**P`,T P  x 4 H ( 8HT @X(\J\s 0.HS P0 J 0B 40J!70dV0!0XA@nicknamect \/w r/w"6eB"@nicknamero/w N/wetoih@sn 1X.1FDQ 1/x8TC47 user_transaction 1F9ct1FQ 1F **9cticl PR41FC471F(@f0D\ticlet0K 0;0&glS$$;@artidX01G@47 grrevtL1G\ 1.9c P1G  1/, 41G471GdV0R0X 0A0&glS88 A@nickname4\0 K_0"6glS"@nickname0P1HD c1/(A0-di!eX47"sp_MSmakeviewproc0|1Ha1/A0&0-dA@viewname\1Hs*1/"60-d"@viewname|1Ha1HC0&0-dC@ownern@ame\1Hs*1H$60-d$@ownername|1Ha 1HA0&0-dDA@procname\1Hs+1H"60-d"@procnamest1Ha!1H;0&0-d;@rgcolT1H s,1H60-d@rgc@lP1H # 1/0-d5I 1H 0-d1H Q1FT0*0-dP 47 Tsp_MSmakeviewproch1H "0060-d0sp_MSmakeviewprocD1H[1/ 0-dH/47SplitNextD1H@ 1//(@sL1HL1H+obL1H&6 1H1He 10Bde /* FLOAT/REAL */ else OdbcPrec(c.xtype,c.length,c.xprec) end) "PR@ECISION", convert(int,case when type_name(d.ss_dtype) IN ('numeric','decimal') then /* decimal/numeric types */ OdbcPrec(c.xtype,c.length,c.xprec)+2 else isnull(d.length, c.length) end) LENGTH, SCALE = convert(smallint, Od@bcScale(c.xtype,c.xscale)), d.RADIX, NULLABLE = convert(smallint, ColumnProperty (c.id, c.name, 'AllowsNull')), REMARKS = convert(varchar(254),null), /* Remarks are NULL */ COLUMN_DEF = text, d.SQL_DATA_TYPE, d.SQL_DATETIME_SUB, @ CHAR_OCTET_LENGTH = isnull(d.length, c.length)+d.charbin, ORDINAL_POSITION = convert(int,c.colid), IS_NULLABLE = convert(varchar(254), rtrim(substring('NO YES',(ColumnProperty (c.id, c.name, 'AllowsNull')*3)+1,3))), SS_DATA_TYPE = c.type @ FROM sysobjects o, master.dbo.spt_datatype_info d, systypes t, syscolumns c LEFT OUTER JOIN syscomments m on c.cdefault = m.id AND m.colid = 1 WHERE o.name like @table_name AND user_name(o.uid) like @table_owner A@ND o.id = c.id AND t.xtype = d.ss_dtype AND c.length = isnull(d.fixlen, c.length) AND (d.ODBCVer is null or d.ODBCVer = @ODBCVer) AND o.type <> 'P' AND isnull(d.AUTO_INCREMENT,0) = isnull(ColumnProperty (c.id, c.name, 'IsIdentity'),0) @ AND c.xusertype = t.xusertype AND c.name like @column_name ORDER BY 2, 3, 17 end 0Zbd1 create procedure sp_scriptpkwhereclause @src_objid int, @src_cols int, @pkcolumns binary(32) as declare @this_col int declare @art_col int declare @spacer nvarchar(10) declare @isset int declare @cmd nvarchar(4000) -- create WHERE clause select @this_col = 1 select @art_col = 1 sele@t @spacer = N' ' select @cmd = N'where' while @this_col <= @src_cols begin exec @isset = dbo.sp_isarticlecolbitset @this_col, @pkcolumns if @isset != 0 and EXISTS (select name from syscolumns where id=@src_objid and @this_col=colid and iscomputed<>1) begin select @cmd = @cmd + @spacer + QUOTENAME(col_name( @src_objid, @this_col)) + N' = @pkc' + convert( nvarchar, @art_col ) select @art_col = @art_col + 1 select @spacer = N' and ' if len( @cmd ) > @000 begin insert into #proctext(procedure_text) values( @cmd ) select @cmd = N'' end end select @this_col = @this_col + 1 end insert into #proctext(procedure_text) values( @cmd ) obj<1H 1Hx8L1H*11/$BdusP1H  1G41H471HV0@1H1H00-d create procedure sp_MSmakeviewproc (@viewname sysname, @ownername sysname, @procname nvarchar(290), @rgcol sysname) as declare @retcode smallint declare @varname nvarchar(10) declare @cmdpiece nvarchar(4000) set nocount on select @procname=QUOTENAME(@procname) set @cmdpiece = 'create procedure dbo.' + @procname + ' (@tablenick int) AS set nocount on set rowcount 0 insert into #belong (tablenick@ rowguid, flag, partchangegen, joinchangegen) select nb.tablenick, nb.rowguid, 0, nb.partchangegen, nb.joinchangegen from #notbelong nb, ' + QUOTENAME(@ownername) + '.' + QUOTENAME(@viewname) + ' v where nb.tablenick = @tablenick and nb.rowguid = v.' + @rgcol + ' if @@ERROR <> 0 begin RAISERROR(''Error selecting from view'' , 16, -1) return (1) end' exec (@cmdpiece) exec dbo.sp_MS_marksystemobject @procname exec ('grant exec on ' + @procname + ' to public') HP1H  1HP1H 1HP1H 1H P1H 1H41H471H́CV0@P|08htT<d0\ );@pname T/',3coX1WDQ1H T$57 user_transaction 1W0-dt1WQ1W **0-d TV41W$571W(@f0D\*<H.L/ .*S ro (X01X@o57 grrevTL1X\ 1G0-d P1X  1H 41Xo571XdV0m0Xblishera\0Nx0$$6T$@publisher0N%0I0&TX1Y<x8 67DMLL1Y7%,f41Y 671Y p0n0TG@publication `0Nx0(6T(@publication0N'0G0&TG@description `0 NXz1Z`/q67;0&T$$;@pubidHT0 Ny0 6T@pubid|0 N)0 C0&T88 C@retention5\0 N}0 $6T$@retention|0NX1[1Z`771Zlq $@sync_mode0N+0E0&T88 E@allow_push91`0Nx0&6T&@allow_pushL0N,0E0&T88  Px1\L87update stats1\S q0RfS` _WA_Sys_optname_53A266ACaH1\J[41\J1\87?@?A0merge0%transactional1\J1\TTJJJ Je1\S1\  WWfSryЀJP1\ H1X41\871\,p0x84d\d Y@enabled_for_internetalt0N}0:6T:@enabled_for_internett0N20Q0&T88 Q@publication_type fl0N0PL1_L87update stats1_S1\0RfS`  hh_WA_Sys_value_53A266ACH1_J1\i 1_J1_87?@? 1_J 1_TTJJJ Je1_S1_  WWfSD  ̀J P1_ 1\H41_871_,p0x88Xd/4/ 7/ V0@/  /0C CREATE PROCEDURE sp_MSsetreplicastatus (@subid uniqueidentifier, @status_value int ) AS /* ** Check to see if current publication has permission */ declare @retcode int exec @retcode=sp_MSreplcheck_connection @repid = @subid if @reX1b<x887DMLtiD1bfS qx8staus 41b871bx8Tturn (1) return (0) &P/   / P/  /P/  / P/  X1c<x8597DMLD1cfS1bscri41c5971cx8Tid int, @columns binary(32) as declare @cmd nvarchar(4000) declare @cmd2 nvarchar(4000) declare @qualname nvXz1d`1Z97ypestring nvarchar(4000) declare @spacer nvarchar(1) declare @ccoltype sysname declare @src_cols int declare @this_col int declare @art_col int X1e1d971dlq s = count(*) from syscolumns where id = @objid exec sp_MSget_qualified_name @objid, @qualname OUTPUT select @cmd2 = N'insert into ' + @qualname + N'( ' P1fD N:7CLEAN DBT1f6Northwind1fl0% A4F CDlNorthwindC:\TEMP\northwnd.mdf1f1fl0% @A4F CDlNorthwindC:\TEMP\northwnd.mdfT1H1f6NorthwindP1f ]%41fN:71f,j0LT\d and colid=@this_col and iscomputed<>1) begin if rtrim(@ccoltype) not like N'timestamp' and ColumnProperty(@objid, @colnafP1hDo:7CLEAN DBL1h1f6pubsf1h1fZ0%Ad4F 9:ZpubsC:\TEMP\pubs.mdfp1h1hZ0%@Ad4F 9:ZpubsC:\TEMP\pubs.mdf@L1h1hH6pubs P1h ]1f41ho:71h,j0l<\ output, 0 end end select @this_col = @this_col + 1 end if @num_col > 0 begin -- save off cmd fragment exec dbo.sp_MSfluP1jD:7CLEAN DBL1j1h6msdbv1j1hb0%A3F 9:bmsdbC:\TEMP\MSDBData.mdf 1j1jb0%@A3F 9:bmsdbC:\TEMP\MSDBData.mdf L1jH1j6msdblP1j ]1h41j:71j,j0|,D\ if @rc = 0 and EXISTS (select name from syscolumns where id=@objid and colid=@this_col and iscomputed<>1) begin if rtrim(@ccoltype) not like N'timestP1lD:7CLEAN DBL1l1j6model1l1j^0%A1F ;<^modelC:\TEMP\model.mdf 1l1l^0%@A1F ;<^modelC:\TEMP\model.mdfuL1l1H6modelP1l ]1j41l:71l,j0t$@\cmd output, 1 insert into #proctext(procedure_text) values( N') ') end else -- set the @@rowcount insert into #proctext(procedure_text) values( N' slX1n`1dL7D c1H$xX1o1nL71n q P1pDL7DIRTY DBL1p1l6model1p1l^0%@A1F ;<^modelC:\TEMP\model.mdf1p1p^0%A1F ;<^modelC:\TEMP\model.mdfL1p1H6modelP1p ]1l41pL71pЫ/t$@\pP1rHM7timestampP1r1p6tempdb1r1pb0% A4F =>btempdbC:\TEMP\tempdb.mdf1r1rb0% AM7F =>btempdbC:\TEMP\tempdb.mdfP1rH1r6tempdbP1r ]1p41rM71rЫ/8L`P1tDN7DIRTY DBL1t1r6msdb1t1rb0%@A3F 9:bmsdbC:\TEMP\MSDBData.mdf1t1tb0%A3F 9:bmsdbC:\TEMP\MSDBData.mdfL1tH1t6msdbP1t ]1r41tN71t`/|,D\P1vDN7DIRTY DBL1v1t6pubs1v1tZ0%@Ad4F 9:ZpubsC:\TEMP\pubs.mdf1v1vZ0%Ad4F 9:ZpubsC:\TEMP\pubs.mdfL1v1vH6pubsP1v ]1t41vN71v`/l<\P1xDN7DIRTY DBT1x1v6Northwind1x1vl0% @A4F CDlNorthwindC:\TEMP\northwnd.mdf1x1xl0% A4F CDlNorthwindC:\TEMP\northwnd.mdfT1H1x6NorthwindP1x ]1v41xN71x`/LT\xX@1zL 0X7update statsP1zS1_4 !P1z 1_41z0X71zx8dP 1{L CX7update stats1{p^ $$$2Ŗ;=;:, 9A '4AN[hu+8ER_ly"/<IVcp} &3@MZgt*7@Q^kx!.;HUbo| %2?LYfs)6CP]jw -:GTan{  $ 1 > K X e r     ( 5 B O \ i v   A  A  A  A  B  B @ C  C  C  C  C  C  C  C  C  C  C  C  C  C  C  D  D  D  D  D  D  D2  D2  D2  D2  DBR DBR DBR DBR DBR DBR DBR DBR DBR DBR DBR DBR DBR DBR D@BR DBR DBR DBR DBR DBR DC  DC  E  E  F  F_U I  I  I  I  IDX J  J  J  J  J  J  J  K  L  L  L  L  L  L  LO  LR  LR  LR  LS  LS  O  O  O @ O9T O9T O9T O9T O9T P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P @P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P @  P  P  P  P  P  P  P  P  P  P  P  PRO R  SFL SFL SOP SOP SOP SOP SRV SRV SRV SRV SRV SRV SRV SRV SRV SRV SRV SRV SRV SRV SRV SRV SRV SRV SRV SRV@ SRV SRV SRV SRV T  T  T  T  T  T  TBO TBO V  V  V CX7V;!=:E.:, @A '4AN[hu+8ER_ly"/<IVcp} &3@M@gt*7DQ^kx!.;HUbo| %2?LYfs)6CP]jw -:GTan{  $ 1 > K X e r     ( 5 B O \ i v    , 9 F S `  A  A  A  @A  B  B  C  C  C  C  C  C  C  C  C  C  C  C  C  C  C  D  D  D  D  D  D  D2  D2  D2  D2  DBR DBR DBR DBR DBR DBR DBR DBR DBR DBR DBR DB@ DBR DBR DBR DBR DBR DBR DBR DBR DC  DC  E  E  F  F_U I  I  I  I  IDX J  J  J  J  J  J  J  K  L  L  L  L  L  L  LNG LNG LNG LNG LNG LNG@ LNG LO  LO  LR  LR  LR  LS  O  O  O  O9T O9T O9T O9T O9T O9T P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P@  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P @ P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  P  PRO R  SFL SOP SOP SOP SOP SOP SRV SRV SRV SRV SRV SRV SRV SRV SRV@SRV SRV SRV SRV SRV SRV SRV SRV SRV SRV SRV SRV SRV SRV SRV T  T  T 1{p1{2[ T  T  T  TBO V  V  V 1{p1{TTTTf$pp8p8HnAp8eTfpx8x8ynAx8eP1{ 1z41{CX71{,/x8ddy RZ DP 1LQX7update stats1p1{p p p 2:EJ;;:,9A !,7BMXcny)4?JU`kv&1<GR]hs~ #.9DOZep{@  +6ALWbmx(3>IT_ju%0;FQ\gr} "-8CNYdoz *5@KValw   ' 2 = H S @     @        #&),/258;>@@@@ADGJMPSVY@\_befhjlnqsux{}@Ve @@@@@@@@@@@@@@@@@@@@@ @ @WQX7G1:S<;:E.:,@A !,7BMXcny)@?JU`kv&1<GR]hs~ #.9DOZep{  +6ALWbmx(3>IT_ju%0;FQ\gr} "-8CNYdoz *5@KValw   ' 2 = H S ^ i t  @@             #&),/258;>@@@@@ADGJMPSVY\_befhjlnqsux{}@ @cf  @@@@@@@@@@@@@@@@@@@ @1p1~ M @@H@1p1TTTTgp p@p8p8ynAp8eTg p@x8x8ynAx8eP1 1{41QX71,/x8@ d4P 2 1L/UX7update statsX1S 1z  !X1S 1 !P1S 1 ``!P1S 18 !P1S 19 !@P1S 1( !P1S 1$ !P1S 1? !1 J1_  }2\:؊<-#;2:E.:,QKA !,7BMXcny@)4?JU`kv&1<GR]hs~ #.9DOZep{  +6ALWbmx(3>IT_ju%0;FQ\gr} "-8CNYdoz *5@KValw   ' 2 = H S ^ i t  @@@@                   @   &/2:=nUX7@\:؊<-#;2:E.:,QKA !,7BMXcny)4?JU`kv&1<GR]hs~ #.9DOZep{  +6ALWbmx(3>IT_ju%0;FQ\gr} "-8CNY@oz *5@KValw   ' 2 = H S ^ i t  @@@                   @@   &/2:=n1 p1TTTTh Jp9p peTh JTx8x8ynAx8eP1 141ZX7H1,/x8TdddP 2  1L/_X7update statsX1S 1  !X1S 1 !P1S 1 ``!P1S 18 !P1S 19 !@P1S 1( !P1S 1$ !P1S 1? !1    28 ;.:=%I<:E.:,A !,7BMXcny@)4?JU`kv&1<GR]hs~ #.9DOZep{  +6ALWbmx(3>IT_ju%0;FQ\gr} "-8CNYdoz *5@KValw   ' 2 = H S ^ i t  @@@@@           @@@@@@@@@@@'j_X7@8 ;.:=%I<:E.:,A !,7BMXcny)4?JU`kv&1<GR]hs~ #.9DOZep{  +6ALWbmx(3>IT_ju%0;FQ\gr} "-8CNY@oz *5@KValw   ' 2 = H S ^ i t  @@@@           @@@@@@@@@@@@'j1 p1 TTTTi p:p peTi Tx8x8ynAx8eP1 1 41_X7H1,/x8TdddX 1DR!-x8!"LcX7update stats 1!41cX71x8\X1`1nX7D c1n$xX11Y71q P1D 6Y7CLEAN DBT11x6Northwind11xl0% A4F CDlNorthwindC:\TEMP\northwnd.mdf11l0% @A4F CDlNorthwindC:\TEMP\northwnd.mdfT1H16NorthwindP1 ]1x416Y71,"0LT\P1DRY7CLEAN DBL116pubs11Z0%Ad4F 9:ZpubsC:\TEMP\pubs.mdf11Z0%@Ad4F 9:ZpubsC:\TEMP\pubs.mdfL11H6pubsP1 ]141RY71,"0l<\P1DsY7CLEAN DBL116msdb11b0%A3F 9:bmsdbC:\TEMP\MSDBData.mdf11b0%@A3F 9:bmsdbC:\TEMP\MSDBData.mdfL1H16msdbP1 ]141sY71,"0|,D\P1DY7CLEAN DBL116model11^0%A1F ;<^modelC:\TEMP\model.mdf11^0%@A1F ;<^modelC:\TEMP\model.mdfL11H6modelP1 ]141Y71,"0t$@\X1`1u7D c1$xX1171 q P61<n87DML1,#?1masterC:\TEMP\master.mdf H [masterc:\mssql7\data\master.mdf6master4171//T P>1<n8A7DML1,#1C3mastlogC:\TEMP\mastlog.ldf H _mastlogc:\mssql7\data\mastlog.ldf6mastlog41A71//T X&1<n87DML11/*bmasterC:\TEMPpmasterc:\mssql7\data6master4171//TPB1<n87DML1,#1A5modeldevC:\TEMP\model.mdf H ]modeldevc:\mssql7\data\model.mdf6modeldev4171//T PF1<n8Z7DML1,#1G5modellogC:\TEMP\modellog.ldf H cmodellogc:\mssql7\data\modellog.ldf6modellog41Z71// T P1D 7CLEAN DBL116model11^0%@A1F ;<^modelC:\TEMP\model.mdf11^0%@A1F ;<^modelC:\TEMP\model.mdfL11H6modelP1 ]14171,/t$@\X1@7 modelL116model11^0%@A1F ;<^modelC:\TEMP\model.mdfP1 ]14171)b/<XX1@7 model11l0%77F ;<lmodelc:\mssql7\data\model.mdfL116model`171D c1$HXX1X1101171q pPX1L116model11l0%77F ;<lmodelc:\mssql7\data\model.mdf11l0%A77F ;<lmodelc:\mssql7\data\model.mdfL116modelL1@16model11l0%A77F ;<lmodelc:\mssql7\data\model.mdf11l0%A77F ;<lmodelc:\mssql7\data\model.mdfL116modelL11@6model1 1l0%A77F ;<lmodelc:\mssql7\data\model.mdf1 1 l0%A77F ;<lmodelc:\mssql7\data\model.mdfL1 1 6modelP1 ]1H41s71n8gl$Dd P>1<n8ߩ7DML1,#1A3tempdevC:\TEMP\tempdb.mdf H ]tempdevc:\mssql7\data\tempdb.mdf6tempdev41ߩ71@00T P>1<n8=7DML1,#1C3templogC:\TEMP\templog.ldf H _templogc:\mssql7\data\TEMPLOG.LDF6templog41=71@00T X:1<n87DML1 ^111C:\TEMP\tempdb.mdf c:\mssql7\DATA\TEMPDB.MDF4171n8TX:1<n87DML1 ^1333C:\TEMP\templog.ldf c:\mssql7\DATA\TEMPLOG.LDF4171n8TXR1<n8Q7DML11 /22@btempdbC:\TEMP\tempdb.mdfptempdbc:\mssql7\DATA\TEMPDB.MDF6tempdb41Q7100TP1D X7CLEAN DBL11 6msdb11b0%@A3F 9:bmsdbC:\TEMP\MSDBData.mdf11b0%@A3F 9:bmsdbC:\TEMP\MSDBData.mdfL1H16msdbP1 ]1 41X71,"/|,D\X1<]7msdbL116msdb11b0%@A3F 9:bmsdbC:\TEMP\MSDBData.mdfP1 ]141]71)b/<TX1<7msdb11p0%A7F 9:pmsdbc:\mssql7\DATA\msdbdata.mdfL116msdb`171HTX1X1101֬71q pPp1L116msdb11p0%A7F 9:pmsdbc:\mssql7\DATA\msdbdata.mdf11p0%A7F 9:pmsdbc:\mssql7\DATA\msdbdata.mdfL116msdb@L116msdb11p0%A7F 9:pmsdbc:\mssql7\DATA\msdbdata.mdf11p0%A7F 9:pmsdbc:\mssql7\DATA\msdbdata.mdfL116msdbL1@16msdb1 1p0%A7F 9:pmsdbc:\mssql7\DATA\msdbdata.mdf1 1 p0%A7F 9:pmsdbc:\mssql7\DATA\msdbdata.mdfL1 1 6msdbP1 ]1H 4171n8g 4L dP1D ݭ7CLEAN DBL11 6pubs11 Z0%@Ad4F 9:ZpubsC:\TEMP\pubs.mdf11Z0%@Ad4F 9:ZpubsC:\TEMP\pubs.mdfL11H6pubsP1 ]1 41ݭ71,0l<\X1<7pubsL116pubs11Z0%@Ad4F 9:ZpubsC:\TEMP\pubs.mdfP1 ]14171)b04TX1<I7pubs11h0%AI7F 9:hpubsc:\mssql7\DATA\pubs.mdfL116pubs`1I71@TX1X11(1\71q pP@1L116pubs11h0%AI7F 9:hpubsc:\mssql7\DATA\pubs.mdf11h0%AI7F 9:hpubsc:\mssql7\DATA\pubs.mdfL116pubsL1@16pubs11h0%AI7F 9:hpubsc:\mssql7\DATA\pubs.mdf11h0%AI7F 9:hpubsc:\mssql7\DATA\pubs.mdfL116pubsL11@pubs1 1h0%AI7F 9:hpubsc:\mssql7\DATA\pubs.mdf1 1 h0%AI7F 9:hpubsc:\mssql7\DATA\pubs.mdfL1 1 6pubsP1 ]1 41H71n8gT|<d6P1D b7CLEAN DBT11 6Northwind11 l0% @A4F CDlNorthwindC:\TEMP\northwnd.mdf11l0% @A4F CDlNorthwindC:\TEMP\northwnd.mdfT1H16NorthwindP1 ]1 41b71,0LT\X1Hb7northwindT116Northwind11l0% @A4F CDlNorthwindC:\TEMP\northwnd.mdfP1 ]141b71)b0X`X1Hɯ7northwind11z0%Aɯ7F CDznorthwindc:\mssql7\DATA\northwnd.mdfT116northwind`1ɯ71h`X1X11P171q pP1T116northwind11z0%Aɯ7F CDznorthwindc:\mssql7\DATA\northwnd.mdf11z0%Aɯ7F CDznorthwindc:\mssql7\DATA\northwnd.mdfT11@6northwindT116northwind11z0%Aɯ7F CDznorthwindc:\mssql7\DATA\northwnd.mdf11z0% Aɯ7F CDznorthwindc:\mssql7\DATA\northwnd.mdfT1@16northwindT116northwind1 1z0% Aɯ7F CDznorthwindc:\mssql7\DATA\northwnd.mdf1 1 z0% Aɯ7F CDznorthwindc:\mssql7\DATA\northwnd.mdfT1H1 6northwindP1 ]1 41971n8gH@80|( l Xz1`17X1171q P1D 7CLEAN DBT11 6northwind11 z0% Aɯ7F CDznorthwindc:\mssql7\DATA\northwnd.mdf11z0% @Aɯ7F CDznorthwindc:\mssql7\DATA\nHrthwnd.mdfT116northwindP1 ]1 4171,0ld\oP1Dϰ7CLEAN DBL116pubs11h0%AI7F 9:hpubsc:\mssql7\DATA\pubs.mdf11h0%@AI7F 9:hpubsc:\mssql7\DATA\pubs.mdfL1H16pubsP1 ]141ϰ71,04H\P1D7CLEAN DBL116msdb11p0%A7F 9:pmsdbc:\mssql7\DATA\msdbdata.mdf11p0%@A7F 9:pmsdbc:\mssql7\DATA\msdbdata.mdfL1H16msdbP1 ]14171,0DP\P1D7CLEAN DBL116model11l0%A77F ;<lmodelc:\mssql7\data\model.mdf11l0%@A77F ;<lmodelc:\mssql7\data\model.mdfL1H16modelP1 ]14171,0<L\X1`17D c1$xX1171 q P1D7DIRTY DBL116model11l0%@A77F ;<lmodelc:\mssql7\data\model.mdf11l0%A77F ;<lmodelc:\mssql7\data\model.mdfL1H16modelP1 ]14171Ы/<L\P1H7timestampP116tempdb11p0% AM7F =>ptempdbc:\mssql7\DATA\TEMPDB.MDF11p0% A7F =>ptempdbc:\mssql7\DATA\TEMPDB.MDFHP116tempdbP1 ]14171Ы/PX`P1 D7DIRTY DBL1 16msdb1 1p0%@A7F 9:pmsdbc:\mssql7\DATA\msdbdata.mdf1 1 p0%A7F 9:pmsdbc:\mssql7\DATA\msdbdata.mdfL1H1 6msdbP1  ]141 71 `/DP\ P1 D7DIRTY DBT1 1 6northwind1 1 z0% @Aɯ7F CDznorthwindc:\mssql7\DATA\northwnd.mdf1 1 z0% Aɯ7F CDznorthwindc:\mssql7\DATA\nHrthwnd.mdfT1 1 6northwindP1  ]1 41 71 `/ld\oP1DW7DIRTY DBL11 6pubs11 h0%@AI7F 9:hpubsc:\mssql7\DATA\pubs.mdf11h0%AI7F 9:hpubsc:\mssql7\DATA\pubs.mdfL1H16pubsP1 ]1 41W71`/4H\P 1@/n7 GhostD1 c1H41 c1+`h41 c1dl41 c1 `h41 c1`h41 c1@H41 c1`h41 c1H^`h8 [@1H41 c1 _`h4171w8Ct@l8XX1`1!7D c1$xX11>71q P 1Dt7CLEAN DBT116northwind41 c1 h`D1 c111z0% Aɯ7F CDznorthwindc:\mssql7\DATA\northwnd.mdf41 cHld11z0% @Aɯ7F CDznorthwindc:\mssql7\DATA\northwnd.mdfT116northwindP1 ]14171,B/h(\1P1D7CLEAN DBL116pubs11h0%AI7F 9:hpubsc:\mssql7\DATA\pubs.mdf11h0%@AI7F 9:hpubsc:\mssql7\DATA\pubs.mdfL1H16pubsP1 ]1 4171,B/4H\P1D7CLEAN DBL116msdb11p0%A7F 9:pmsdbc:\mssql7\DATA\msdbdata.mdf11p0%@A7F 9:pmsdbc:\mssql7\DATA\msdbdata.mdfL1H16msdbP1 ]14171,B/DP\P1D7CLEAN DBL116model11l0%A77F ;<lmodelc:\mssql7\data\model.mdf11l0%@A77F ;<lmodelc:\mssql7\data\model.mdfL1H16modelP1 ]14171,B/<L\-6234-,g,0AA end end /* ** If article resolver is 'SP resolver', make sure that resolver_info refers to an SP or XP; ** Also make sure it is stored with owner qualification */ if @article_resolver = @sp_resolver begin if not exists (select * from sysobjects where id = object_id(@resolver_info) and ( type = 'P' or type = 'X')) begin select @resolver_info_len =datalength(@resolver_info) raiserror(2812, 16, -1, @resolver_info_len, @resolver_info) return (1) end select @sp_name = name, @sp_owner=user_name(uid) from sysobjects where id = object_id(@resolver_info) select @resolver_info = QUOTENAME(@sp_owner) + '.' + QUOTENAME(@sp_name) end /* ** Validate the resolver procedure for the article - should be either a stored proc or an extended procedure. */ if @resolver_info IS NOT NULL begin /* ** Get the distributor info */ EXEC @retcode = dbo.sp_helpdistributor @rpcsrvname = @distributor OUTPUT IF @@error <> 0 OR @retcode <> 0 OR @distributor IS NULL BEGIN RAISERROR (20036, 16, -1) RETURN (1) END select @distproc = RTRIM(@distributor) + '.master.dbo.xp_regread' /* Don't force different resolver than one that was passed in. */ end /* ** Add article to sysmergearticles and update sysobjects category bit. */ begin tran save TRAN sp_addmergearticle select @artid = artid from sysmergearticles where objid = OBJECT_ID(@qualified_name) select @statusid = 1 /*default status is inactive */ if @artid is NULL begin set @artid = newid() if @@ERROR <> 0 goto FAILURE execute @retcode = dbo.sp_Mgentablenickname @tablenick output, @nickname, @objid if @@ERROR <> 0 OR @retcode <> 0 goto FAILURE end /* Clone the article properties if article has already been published (in a different pub) */ else begin /* ** Parameter Check: @article, @publication. ** Check if the table already exists in this publication. */ if exists (select * from sysmergearticles where pubid = @pubid AND artid = @artid) begin raiserror (14030, 16, -1, @article, @publication) goto FAILURE end /* Make sure that coltracking option matches */ if exists (select * from sysmergearticles where artid = @artid and column_tracking <> @column_tracking_id) begin raiserror (20030, 16, -1, @article) goto FAILURE end /* Reuse the article nickname if article has already been published (in a different pub)*/ select @tablenick = nickname from sysmergearticles where artid = @artid if @tablenick IS NULL goto FAILURE /* Make sure that @resolver_clsid matches the existing resolver_clsid */ select @resolver_clsid_old = resolver_clsid from sysmergearticles where artid = @artid if ((@resolver_clsid IS NULL AND @resolver_clsid_old IS NOT NULL) OR (@resolver_clsid IS NOT NULL AND @resolver_clsid_old IS NULL) OR (@resolver_clsid IS NOT NULL AND @resolver_clsid_old IS NOT NULL AND @resolver_clsid_old <> @resolver_clsid)) begin raiserror (20037, 16, -1, @article) goto FAILURE end /* Insert to articles, copying some stuff from other article row */ H/6SplitNext8-,  V0L- ,Pl/D- -l/@8- , x8L-h0gL-g-^hL-,SghL- ),TAAhP-  ,U4-6-V0-h-0AA set rowcount 1 insert into sysmergearticles (name, type, objid, sync_objid, artid, description, pre_creation_command, pubid, nickname, colum_tracking, status, conflict_table, creation_script, conflict_script, article_resolver, resolver_clsid, ins_conflict_proc, schema_option, destination_object, subset_filterclause, view_type, resolver_info, gen_cur) -- use top 1, distinct could return more than one matching row if status different on partitioned articles select top 1 @article, type, objid, @sync_objid, @artid, @description, @precmdid, @pubid, nickname, column_tracking, 1, conflict_table, @creation_script, conflict_script, article_resolver, resolver_clsid, ins_conflict_proc, @schema_option, @destination_object, @subset_filterclause, 0, resolver_info, gen_cur from sysmergearticles where artid = @artid set rowcount 0 /* Jump to end of transaction */ goto DONE_TRAN end /* Add the specific GUID based repliation columns to sys articles */ insert sysmergearticles (name, objid, sync_objid, artid, type, description, pubid, nickname, column_tracking, status, schema_option, pre_creation_command, destination_object, article_resolver, resolver_clsid, subset_filterclause, view_type, resolver_info) values (@article, @objid, @sync_objid, @artid, @typeid, @description, @pubid, @tablenick, @column_tracking_id, @statusid, @schema_option, @precmdid, @estination_object, @article_resolver, @resolver_clsid, @subset_filterclause, 0, @resolver_info) if @@ERROR <> 0 goto FAILURE exec @retcode = dbo.sp_replupdateschema @qualified_name if @@ERROR <> 0 or @retcode <> 0 goto FAILURE update sysobjects set replinfo = (replinfo | @merge_pub_object_bit) where id = @objid if @@ERROR <> 0 goto FAILURE /* Make a generation */ execute @retcode = dbo.p_MSmakegeneration if @@ERROR <> 0 goto FAILURE /* If the article status is active then publish the user tables */ if @status = 'active' begin /* Get a holdlock on the underlying table */ select @cmd = 'select * into #tab1 from ' select @cmd = @cmd + @qualified_name select @cmd = @cmd + '(TABLOCK HOLDLOCK) where 1 = 2 ' execute(@cmd) /* Ad the guid column to the user table */ execute @retcode = dbo.sp_MSaddguidcolumn @source_owner, @source_object if @@ERROR <> 0 OR @retcode <> 0 -- NOTE: new change goto FAILURE /* Create an index on the rowguid column in the user table */ execute @retcode = dbo.sp_MSaddguidindex @source_owner, @source_object if @@ERROR <> 0 OR @retcode <> 0 goto FAILURE /* Crete the merge triggers on the base table */ execute @retcode = dbo.sp_MSaddmergetriggers @qualified_name, @column_tracking_id if @@ERROR <> 0 OR @retcode <> 0 goto FAILURE /* Create the merge insert/update stored procedures for the base table */ execute @retcode = dbo.sp_MSsetartprocs @publication, @article if @@ERROR <> 0 OR @retcode <> 0 goto FAILURE /* Set te article status to be active so that Snapshot does not do this again */ select @statusid = 2 /* Active article */ update sysmergearticles set status = @statusid where artid = @artid if @@E- h- i0AAiRROR <> 0 goto FAILURE end DONE_TRAN: /* ** For articles with subset filter clause - set the pub type to subset */ if len(@subset_filterclause) > 0 begin execute @retcode = dbo.sp_MSsubsetpublication @publication if @@ERROR <> 0 or @retcode<>0 goto FAILURE end /* ** 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 @dbname = DB_NAME() SELECT @distproc = RTRIM(@distributor) + '.' + @distribdb + '.dbo.sp_MSadd_article' EXECUTE @retcode = @distproc @publisher = @@SERVERNAME, @publisher_db = @dbname, @publication = @publication, @article = @article, @destination_object = @destination_object, @source_owner = @source_owner, @source_object = @source_object, @description = @description -- @article_id = NULL IF @@ERROR <> 0 or @retcode <> 0 BEGIN goto FAILURE END COMMIT TRAN /* If the article status is active adding the merge triggers to the base table */ return (0) FAILURE: RAISERROR (20009, 16, -1, @article, @publication) if @@TRANCOUNT > 0 begin ROLLBACK TRANSACTION sp_addmergearticle COMMIT TRANSACTION end return (1) MSmP-  - P- -P- - #P- -4,6,rtd228211"4PP+:4+:x76+:́Cc0d##"t"$"l8`0L|hH Hp@\*hadsdc n S 4-*D2,BT6 user_transaction -*AAt-*2-* **AA VrXame4-*6-*(@Q0D\e int SET NOCOUNT ON -- sp_unsubscribe has to be callled from a remote subscriber -- If not, w0-+@O6 grrevL-+& ,AA P-+  - 4-+O6-+dV0X0Xicationl`+M{[+: (6=)_(@publicationx+M{+M?0&=)_:Tpr-,D c,(Aze`6*sp_changemergearticle-,, G0&zeG@publication`-,v>,)(6ze(@publicationx-,-,?0&ze?@articleX-,v>-, 6ze @article|-,-,A0&zeA@propertyd\-,v?-,"6ze"@propertyt-,-,;0&ze;@valueT-, vA-,6zevalueP-, S ,@zeeP-, S -, ze ^P-, S -, zeP-, U -, zeӞ:P-,S -,zeP-,S -,zer -,ze-,R(\0*zeP 6 \sp_changemergearticlep-,R,C86ze8sp_changemergearticleD-,Z9,D ze-,'J 0ze CREATE PROCEDURE sp_changemergearticle ( @publication sysname, /* Publicatin name */ @article sysname, /* Article name */ @property sysname = NULL, /* The property to change */ @value nvarchar(2000) = NULL /* The new property value */ ) AS SET NOCOUNT ON /* ** Declarations. */ declare @resolver_info_len int declare @sp_resolver sysname declare @db_name sysname declare @artid uniqueidentifier declare @pubid uniqueidentifier declare @artidsr nvarchar(38) declare @pubidstr nvarchar(38) declare @object sysname declare @owner sysname declare @resolver_clsid nvarchar(50) declare @article_resolver nvarchar(255) declare @retcode int declare @statusid int declare @precmdid tinyint declare @regkey nvarchar(255) declare @distributor sysname declare @distproc nvarchar(255) declre @schemaversion int declare @schemaguid uniqueidentifier declare @schematype int declare @schematext nvarchar(2000) /* ** Security Check */ EXEC @retcode = dbo.sp_MSreplcheck_publish IF @@ERROR <> 0 or @retcode <> 0 return (1) /* ** Check to see if the database has been activated for publication. */ if (select category & 4 FROM master..sysdatabases WHERE name = DB_NAME()) = 0 BEGIN RAISERROR (14013, 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 begin raiserror (14027, 11, -1, @publication) return (1) end select @db_name = db_name from sysmergesubscriptions where (pubid=@pubid) and (subid=@pubid) IF @db_name <> db_name() BEGIN RAISERROR (20047, 16, -1) RETURN (1) END /* ** Parameter Check: @property. ** If the @property parameter is NULL, print the options. */ if @property IS NULL BEGIN CREATE TABLE #tab1 (properties sysname) INSERT INTO #tab1 VALUES ('description') INSERT INTO #tab1 VALUES ('pre_creation_command') INSERT INTO #tab1 VALUES ('creation_script') INSERT INTO #tab1 VALUES (column_tracking') INSERT INTO #tab1 VALUES ('article_resolver') INSERT INTO #tab1 VALUES ('resolver_info') INSERT INTO #tab1 VALUES ('status') INSERT INTO #tab1 VALUES ('subset_filterclause') INSERT INTO #tab1 VALUES ('schema_option') select * FROM #tab1 RETURN (0) END /* ** Parameter Check: @property. ** Check to make sure that @property is a valid property in ** sysmegearticles. */ if @property IS NULL OR LOWER(@property) NOT IN ('name', 'description', 'pre_creation_command', 'creation_script', 'column_tracking', 'article_resolver', 'reslver_info', 'status', 'subset_filterclause', 'schema_option') BEGIN RAISERROR (20019, 16, -1) RETURN (1) END e H/6SplitNextD-, -m/ s@p_L-,iL-,-,=i'L-,"oic -,i-,x0txcreate procedure sp_who --- 1995/11/28 15:48 @loginame sysname = NULL --or 'active' as declare @spidlow int, @spidhigh int, @spid int, @sid varbinary(85) select @spidlow = 0 ,@spidhigh = 32767 if ( @loginameis not NULL AND upper(@loginame) = 'ACTIVE' ) begin select spid ,status ,loginame=rtrim(loginame) ,hostname ,blk=convert(char(5),blocked) ,dbname= db_name(dbid),cmd from master.dbo.sysprocesses where spid >= @spidlow and spid <= @spidhigh AND upper(cmd) <> 'AWAITING COMMAND' return (0) end if (@loginame is not NULL AND upper(@loginame) <> 'ACTIVE' ) begin if (@loginame like '[0-9]%') -- is a spid. begin select @spid = conver(int, @loginame) select spid, status, loginame=rtrim(loginame), hostname,blk = convert(char(5),blocked), dbname=db_name(dbid), cmd from master.dbo.sysprocesses where spid = @spid end else begin select @sid = suser_sid(@loginame) if (@sid is null) begin raiserror(15007,-1,-1,@loginame) return (1) end select spid, status, loginame=rtrim(loginame), hostname ,blk=convert(char(5),blocked), dbname=db_name(dbid), cmd from master.dbo.sysprocesses where sid = @sid end return (0) end /* loginame arg is null */ select spid, status, loginame=rtrim(loginame), hostname, blk=convert(char(5),blocked), dbname=db_name(dbid), cmd from master.dbo.sysprocesses where spid >= @spidlow and spid <= @spidhigh return (0) -- sp_who 0o -- Set a profile as a default for an agent_type create procedure sp_MSupdate_agenttype_default( @profile_id int ) as set nocount on declare @agent_type int /* This profile must have been defined for this agent type */ if not exists ( select * from msdb..MSagent_profiles where profile_id = @profile_id ) BEGIN RAISERROR (20066, 16, -1) -- profile not defined RETURN (1) END select @agent_type = agent_type from msdb..MSagent_profiles where profile_id = @profile_id BEGIN TRAN update msdb..MSagent_profiles set def_profile = 0 where agent_type = @agent_type and def_profile = 1 if @@error <> 0 goto UNDO update msdb..MSagent_profiles set def_profile = 1 where profile_id = @profile_id if @@error <> 0 goto UNDO COMMIT TRAN return 0 UNDO: if @@trancount = 1 rollback tran else commit tran return 1 <-, -,i x8L-,)- zeiP-,  -+4-,6-,V0-,i-,0ze /* ** Parameter Check: @publication. ** Make sure that the publication exists. */ if @publication IS NULL BEGIN RAISERROR (14043, 16, -1, '@publication') RETURN (1) END select @pubid = pubid from sysmergepublicatins where name = @publication and UPPER(publisher)=UPPER(@@servername) and publisher_db=db_name() if @pubid IS NULL BEGIN RAISERROR (20026, 16, -1, @publication) RETURN (1) END /* ** Check to see that the article exists in sysmergearticles. ** Fetch the article identification number. */ if @article IS NULL BEGIN RAISERROR (14043, 16, -1, '@article') RETURN (1) END selct @artid = artid FROM sysmergearticles WHERE name = @article AND pubid = @pubid if @artid IS NULL BEGIN RAISERROR (20027, 16, -1, @article) RETURN (1) END set @artidstr = '''' + convert(nchar(36), @artid) + '''' set @pubidstr = '''' + convert(nchar(36), @pubid) + '''' select @sp_resolver = 'Microsoft SQLServer Stored Procedure Resolver' /* ** Change the property. */ if LOWER(@property) = 'column_tracking' BEGIN /* ** This property can be modified for articles belonging to publications that are not active. */ if EXISTS (select status FROM sysmergearticles WHERE artid = @artid AND status = 2) BEGIN RAISERROR (20043, 16, -1, @article) RETURN (1) END /* ** Check to make sure that we have a valid type. */ if LOWER(@value) NOT I ('true', 'false') BEGIN RAISERROR (14137, 16, -1) RETURN (1) END /* ** Update the syssubsetdefintions table with the new column tracking. */ if LOWER(@value) = 'true' update sysmergearticles set column_tracking = 1 where artid=@artid else update sysmergearticles set column_tracking = 0 where artid=@artid f @@ERROR <> 0 RETURN (1) END if LOWER(@property)='description' BEGIN UPDATE sysmergearticles SET description = @value WHERE artid = @artid and pubid = @pubid AND pubid = @pubid if @@ERROR <> 0 RETURN (1) END if LOWER(@property) ='creation_script' BEGIN update sysmergearticles set creation_script=@value where artid=@artid and pubid=@pubid if @@ERROR <> 0 RETURN (1) END if LOWER(@property) = 'subset_filterclause' BEGIN /* ** This property can be modified for articles belonging to publications that are not active. */ if EXISTS (select status FROM sysmergearticles WHERE artid = @artid AND pubid = @pubid AND status = 2) BEGIN RAISERROR (20043, 16, -1, @article) RETURN (1) END update sysmerearticles set subset_filterclause = @value where artid=@artid and pubid=@pubid if @@ERROR<>0 return (1) /* ** set the pub type to subset or full as appropriate */ execute @retcode = dbo.sp_MSsubsetpublication @publication if @@ERROR <> 0 OR @retcode <> 0 RETURN (1) END if LOWER(@property) ='article_resolver' BEGIN if @value IS NULL OR @value 'default' OR @value = '' begin set @article_resolver = NULL f @H/6SplitNextD-,! -,n/ct @objL-,"j0iL-,#i-, fljblL-,$-,ij -,%j-,#x0txcreate procedure sp_who --- 1995/11/28 15:48 @loginame sysname = NULL --or 'active' as declare @spidlow int, @spidhigh int, @spid int, @sid varbinary(85) select @spidlow = 0 ,@spidhigh = 32767 if ( @loginame is not NULL AND upper(@loginame) = 'ACTIVE' ) begin select spid ,status ,loginame=rtrim(loginame) ,hostname ,blk=convert(char(5),blocked) ,dbname= db_namedbid),cmd from master.dbo.sysprocesses where spid >= @spidlow and spid <= @spidhigh AND upper(cmd) <> 'AWAITING COMMAND' return (0) end if (@loginame is not NULL AND upper(@loginame) <> 'ACTIVE' ) begin if (@loginame like '[0-9]%') -- is a spid. begin select @spid = convert(int, @loginame) select spid, status, loginame=rtrim(loginame), hostname,blk = convert(char(5),blocked), dbname=db_name(dbid), cmd from master.dbo.sysprocesses were spid = @spid end else begin select @sid = suser_sid(@loginame) if (@sid is null) begin raiserror(15007,-1,-1,@loginame) return (1) end select spid, status, loginame=rtrim(loginame), hostname ,blk=convert(char(5),blocked), dbname=db_name(dbid), cmd from master.dbo.sysprocesses where sid = @sid end return (0) end /* loginame arg is null */ select spid, status, loginame=rtrim(loginame), hostname, blk=conver(char(5),blocked), dbname=db_name(dbid), cmd from master.dbo.sysprocesses where spid >= @spidlow and spid <= @spidhigh return (0) -- sp_who 0o -- Set a profile as a default for an agent_type create procedure sp_MSupdate_agenttype_default( @profile_id int ) as set nocount on declare @agent_type int /* This profile must have been defined for this agent type */ if not exists ( select * from msdb..MSagent_profiles where profileid = @profile_id ) BEGIN RAISERROR (20066, 16, -1) -- profile not defined RETURN (1) END select @agent_type = agent_type from msdb..MSagent_profiles where profile_id = @profile_id BEGIN TRAN update msdb..MSagent_profiles set def_profile = 0 where agent_type = @agent_type and def_profile = 1 if @@error <> 0 goto UNDO update msdb..MSagent_profiles set def_profile = 1 where profile_id = @profile_id if @@error <> 0 goto UNDO COMMIT TRAN return 0 UNDO: if @@trancount = 1 rollback tran else commit tran return 1 n<-,& i-,$j x8L-,')-,tjstP-,(  -,4-,!6-,!V0-, i-,'0eset @resolver_clsid = NULL end else begin EXECUTE @retcode = master.dbo.xp_regread 'HKEY_LOCAL_MACHINE', 'SOFTWARE\Microsoft\MSSQLServer\Replication\ArticleResolver', @value, @param = @resolver_clsid OUTPUT IF @@ERROR <> 0 or @retcode <> 0 or @resolvr_clsid IS NULL BEGIN RAISERROR (20020, 16, -1) RETURN (1) END end /* ** Update the appropriate column in sysmergearticles with the new article resolver name. ** Note this could affect multiple publication if the same table spans publications */ /* NOTE: new change */ begin tran save TRANSACTION change_article exec @retcode = dbo.sp_MSchangearticleresolver @value, @resolver_clsid, @artid if @@ERROR <> 0 OR @retcode <> 0 begin if @@TRANCOUNT > 0 begin ROLLBACK TRANSACTION change_article COMMIT TRANSACTION end RETURN (1) end declare one_pub CURSOR LOCAL FAST_FORWARD FOR select DISTINCT pubid from sysmergearticles where artid=@artid FOR READ ONLY open one_pub fetch next from one_pub into @pubid while (@@fetch_status <> -1) begin select @schemaversion = schemaversion from sysmergeschemachange if (@schemaversion is NULL) set @schemaversion = 1 else select @schemaversion = 1 + max(schemaversion) from sysmergeschemachange set @schemaguid = newid() set @schematype = 8 if @value is not NULL and @value <> '' select @schematext = 'exec dbo.sp_MSchangearticleresolver ' + '''' + @value + '''' + ',' + '''' + @resolver_clsid + ''' + ',' + '''' + convert(nchar(36), @artid) + '''' else select @schematext = 'exec dbo.sp_MSchangearticleresolver NULL, NULL,' + '''' + convert(nchar(36), @artid) + '''' exec @retcode = dbo.sp_MSinsertschemachange @pubid, @artid, @schemaversion, @schemaguid, @schematype, @schematext if @@ERROR <> 0 OR @retcode <> 0 begin if @@TRANCOUNT > 0 begin ROLLBACK TRANSACTION change_article COMMIT TRANSACTION end RETURN (1) end fetch next from one_pub into @pubid end close one_pub dealocate one_pub COMMIT TRANSACTION END /* for property = 'article_resolver' */ if LOWER(@property) ='resolver_info' BEGIN /* allow non-sp's as resolver info; don't change the resolver class */ select @article_resolver = article_resolver, @resolver_clsid = resolver_clsid from sysmergearticles where artid = @artid -- Use empty stH/6SplitNextD,, -,"o/@L-,-k0ijL-,.i-,+jkL-,/j-,&i*kL-,0)-,(zekP-,1  -,)4-,,6-,,V0-,k-,.0zering for nulls so that schema text won't be null if @article_resolver is null set @article_resolver = '' if @resolver_clsid is null set @resolver_clsid = '' if @value is null set @value = '' if @article_resolver = @sp_resolver begin if not exists (select * from sysobjects where id = object_id(@value) and ( type = 'P' or type = 'X')) begin select @resolver_info_len = datalengh(@value) raiserror(2812, 16, -1, @resolver_info_len, @value) return (1) end end /* ** Update the appropriate column in sysmergearticles with the new resolver info. ** Note this could affect multiple publication if the same table spans publications */ BEGIN TRANSACTION exec @retcode = dbo.sp_MSchangearticleresolver @article_resolver, @resolver_clsid, @artid, @value if @@ERROR <> 0 OR @retcode <> 0 begin if @@TRANCOUNT > 0 begin ROLLBACK TRANSACTION change_article COMMIT TRANSACTION end RETURN (1) end declare one_pub CURSOR LOCAL FAST_FORWARD FOR select DISTINCT pubid from sysmergearticles whereartid=@artid FOR READ ONLY open one_pub fetch next from one_pub into @pubid while (@@fetch_status <> -1) begin select @schemaversion = schemaversion from sysmergeschemachange if (@schemaversion is NULL) set @schemaversion = 1 else select @schemaversion = 1 + max(schemaversion) from sysmergeschemahange set @schemaguid = newid() set @schematype = 8 select @schematext = 'exec dbo.sp_MSchangearticleresolver ' + '''' + @article_resolver + '''' + ',' + '''' + @resolver_clsid + '''' + ',' + '''' + convert(nchar(36), @artid) + '''' + ',' + '''' + @value + '''' exec @retcode = dbo.sp_MSinsertschemachange @pubid, @artid, @schemaversion, @schemaguid, @schematype, @schematext if @@ERROR <> 0 OR @retcode <> 0 begin if @@TRANCOUNT = 1 ROLLBACK TRANSACTION else COMMIT TRANSACTION RETURN (1) end fetch next from one_pub into @pubid en close one_pub deallocate one_pub COMMIT TRANSACTION END /* for property = 'resolver_info' */ if LOWER(@property) = 'pre_creation_command' BEGIN /* ** Check to make sure that we have a valid pre_creation_cmd. */ if LOWER(@value) NOT IN ('none', 'drop', 'delete', 'truncate') BEGIN RAISERROR (14061, 16, -1) RETURN () END /* ** Determine the integer value for the pre_creation_cmd. */ if LOWER(@value) = 'none' select @precmdid = 0 else if LOWER(@value) = 'drop' select @precmdid = 1 else if LOWER(@value) = 'delete' select @precmdid = 2 else if LOWER(@value) = 'truncate' select @precmdid = 3 /*  -,4k-,4N 0zeN ** Update the article with the new pre_creation_cmd. */ UPDATE sysmergearticles SET pre_creation_command = @precmdid WHERE artid = @artid AND pubid = @pubid if @@ERROR <> 0 RETURN (1) END if LOWER(@property) = 'status' BEGIN /* ** Check to make sure that we have a valid status */ if LOWER(@value) NOT IN ('active', 'unsynced') BEGIN RAISERROR (20075, 16, -1) RETURN (1) END /* ** Determine the integer value for the type. */ if LOWER(@value) = 'unsynced' select @statusid = 1 else if LOWER(@value) = 'active' select @statusid = 2 /* ** Update the article with the nw type. The same base table might be ** in multiple publications - so qualify with pubid. */ UPDATE sysmergearticles SET status = @statusid WHERE artid = @artid and pubid = @pubid if @@ERROR <> 0 RETURN (1) END IF LOWER(@property) = 'schema_option' BEGIN IF @value IS NULL BEGIN RAISERROR(14146, 16,1) RETURN (1) END CREATE TABLE #tab_changearticle (value binary(8) NULL) IF @@ERROR <> 0 BEGIN RETURN (1) END EXEC ('insert #tab_changearticle values (' + @value +')' ) IF @@ERROR <> 0 BEGIN RETURN (1) END UPDATE sysmergearticles SET schema_option = tab.value from #tab_changearticle tab WHERE artid = @artid AND pubid = @pubid if @@ERROR <> 0 BEGIN DROP TABLE #tab_changearticle RETURN (1) END DROP TABLE #tab_changearticle IF @@ERROR <> 0 BEGIN RETUN (1) END END /* ** Return succeed. */ RETURN (0) P-,5  -,2P-,6 -,6P-,7 -,7 P-,8 -,84-,6-,d o\o onlncSSpS$SRR@RQQAA@A@@55T554|4$X$$##hDT L\ Dl<\vhCL,\ ,#Ft P,  , 4,ݭ6,dV0X0X, @immediate_sync, @art_name, @sub_name, @dest_db, @sync_type, @subscription_type, @login_name END CLOSE hCresyncsub DEAR e 1d c t+-l ' ez _th(=g iN eo t or' ato@r-eDR-,x8T56 user_transaction -ezet-eR-e **ze_own \^4-e56-e(@Q0D\source_owner,b,I0&\ju0-f@6 grrev*L-f+ -+ze P-f  -,9 4-f6-fdV00X ,\juLLP,  , \ju P,  ,  -gD c-,(Ap6:sp_helpallowmerge_publicationP-ge -, -g-gR -el0*P 6 lsp_helpallowmerge_publication-g-,H6Hsp_helpallowmerge_publicationD-gZ@-, 4-g-,%0 CREATE PROCEDURE sp_helpallowmerge_publication AS declare @srvid int declare @db_name sysname /* Select srvid = 0 for the local server name */ select @srvid = 0 select @db_name = db_name() if exists (select name from sysobjects where name='sysmergesubcriptions') if exists (select priority from sysmergesubscriptions where db_name=@db_name and srvid = @srvid and priority=0) begin select 0 RETURN (0) end select 1 @P-g  -fP-g -g P-g -g 4-g6-ǵCJ0x`<\did, 2) is null)) exec ('create unique index ' + @indexname + ' on ' + @qualified_name + ' (' + @colname + ')') if @@ERROR <>0 return (1) return (0) iP,  ,P, ,P, , P, ,4(s-kDR -gT a6 user_transaction -k t-k R -k ** ln4-k a6-k(@Q0D\qa  P+  + qam *P+(i\-lD c-g(A%\!6&sp_helpmergearticle-l!!-, G0&G@publication`-l!v\-, (6(@publicationx-l!"-l?0&?@articleX-l!v\-l 6 @articleP-l! -g -l!-l!R-kX0*P 6 Xsp_helpmergearticlel-l !A-g464sp_helpmergearticleD-l !ZF-g -l !"*0 CREATE PROCEDURE sp_helpmergearticle ( @publication sysname = '%', /* The publication name */ @article sysname = '%' /* The article name */ ) AS SET NOCOUNT ON /* ** Declarations. */ declare @retcode int /* ** Running sp_help is OK from everywhere, whether enabled for publishing or not */ IF not exists (select * from syobjects where name= 'sysmergesubscriptions') RETURN (0) /* ** Security Check. To public. */ /* ** Parameter Check: @publication. ** Check to make sure that the publication exists, that it conforms ** to the rules for identifiers, and that it isn't NULL. */ if @publication IS NULL BEGIN RAISERROR (14043, 16, -1, '@publication') RETURN (1) END /* ** Create a temporary table to hold all inormation. */ create table #helpmergearticle ( id int identity NOT NULL, name sysname NOT NULL, source_owner sysname NOT NULL, source_object sysname NOT NULL, /* converted from objid */ sync_object_owner sysname NOT NULL, sync_object sysname NOT NULL, /* converted from syncobjid */ description nvarchar(255) NULL, status tinyint NULL, creation_script nvarchar(127) NULL, conflict_table nvarchar(258) NULL, article_resolver nvarchar(255) NULL, subset_filterclause nvarchar(2000) NULL, pre_creation_command tinyint NULL, schema_option binary(8) NULL, type tinyint NULL, column_tracking int NOT NULL, resolver_info nvarchar(255) NULL ) if @publication <> '%' BEGIN if NOT EXISTS (select pubid FROM sysmergepublications WHERE name = @publication and UPPER(publisher)=UPPER(@@servername) and publisher_db=db_name()) BEGIN RAISERROR (20026, 16, -1 @publication) RETURN (1) END END /* ** Parameter Check: @article. ** Check to make sure that the article exists, that it conforms ** to the rules for identifiers, and that it isn't NULL. */ if @article IS NULL BEGIN RAISERROR (14043, 16, -1, '@article') RETURN (1) END if @article <> '%' BEGIN if NOT EXISTS (select * FROM symergearticles WHERE name = @article AND pubid IN (select pubid FROM sysmergepublications WHERE name like @publication and UPPER(publisher)=UPPER(@@servername) and publisher_db=db_name())) BEGIN RAISERROR (20027, 16, -1, @article) RETURN (1) END END INSERT INTO #helpmergearticle (name, source_owner, source_object, sync_object_owner, sync_object, description, status, creation_script, conflict_table, pre_creation_command, schema_option, type, column_tracking, article_resolver, subset_filterclause, resolver_info)( select art.name, users.name, bjecn H"/6SplitNextD-l  "-,-p/r('@reaL-l"lL-l"-l n_lgiL-l"'l,Phh8\ 2&^EP&^F 2o s, _fs -w-l"l-l0 CREATE PROCEDURE sp_helpmergearticle ( @publication sysname = '%', /* The publication name */ @article sysname = '%' /* The article name */ ) AS SET NOCOUNT ON /* ** Declarations. */ declare @retcode int /* ** Running sp_help is OK from everywhere, whether enabled for publishing or not */ IF not exists (select * from syobjects where name= 'sysmergesubscriptions') RETURN (0) /* ** Security Check. To public. */ /* ** Parameter Check: @publication. ** Check to make sure that the publication exists, that it conforms ** to the rules for identifiers, and that it isn't NULL. */ if @publication IS NULL BEGIN RAISERROR (14043, 16, -1, '@publication') RETURN (1) END /* ** Create a temporary table to hold all inormation. */ create table #helpmergearticle ( id int identity NOT NULL, name sysname NOT NULL, source_owner sysname NOT NULL, source_object sysname NOT NULL, /* converted from objid */ sync_object_owner sysname NOT NULL, sync_object sysname NOT NULL, /* converted from syncobjid */ description nvarchar(255) NULL, status tinyint NULL, creation_script nvarchar(127) NULL, conflict_table nvarchar(258) NULL, article_resolver nvarchar(255) NULL, subset_filterclause nvarchar(2000) NULL, pre_creation_command tinyint NULL, schema_option binary(8) NULL, type tinyint NULL, column_tracking int NOT NULL, resolver_info nvarchar(255) NULL ) if @publication <> '%' BEGIN if NOT EXISTS (select pubid FROM sysmergepublications WHERE name = @publication and UPPER(publisher)=UPPER(@@servername) and publisher_db=db_name()) BEGIN RAISERROR (20026, 16, -1 @publication) RETURN (1) END END /* ** Parameter Check: @article. ** Check to make sure that the article exists, that it conforms ** to the rules for identifiers, and that it isn't NULL. */ if @article IS NULL BEGIN RAISERROR (14043, 16, -1, '@article') RETURN (1) END if @article <> '%' BEGIN if NOT EXISTS (select * FROM symergearticles WHERE name = @article AND pubid IN (select pubid FROM sysmergepublications WHERE name like @publication and UPPER(publisher)=UPPER(@@servername) and publisher_db=db_name())) BEGIN RAISERROR (20027, 16, -1, @article) RETURN (1) END END INSERT INTO #helpmergearticle (name, source_owner, source_object, sync_object_owner, sync_object, description, status, creation_script, conflict_table, pre_creation_command, schema_option, type, column_tracking, article_resolver, subset_filterclause, resolver_info)( select art.name, users.name, bjec <-w "-llx8L-w")'-,1l$P-w " -g 4-l "6-l V0@ -l !l-w 0 ts.name, users.name, syncobjects.name, art.description, art.status, art.creation_script, art.conflict_table, art.pre_creation_command, art.schema_option, art.type, art.column_tracking, art.article_resolver, art.subset_filterclause, art.resolver_info FROM sysmergearticles art, sysmergepublications pubs, sysobjects objects, sysobjects syncobjects, sysusers users WHERE art.name LIKE @article AND art.pubid = pubs.pubid AND pubs.name LIKE @publication AND UPPER(pubs.publisher) = UPPER(@@servername) AND pubs.publisher_db = db_name() AND objects.id = art.objid AND objects.uid = users.uid AND syncobjects.id = art.sync_objid AND syncobjects.uid = users.uid) order by art.nickname desc select * from #helpmergearticle RETURN (0) P-w ! -wP-w !-wP-w !-w P-w !-w 4-l!6-ler.DTDngD+ o s, _fs-DR-l hT#B6 user_transaction -#t-#R- **cke @ XZ4-#B6-(@Q0D\@c|,2,C0&@]yC@tablename0-@$6 grrevaL-$3 -f P- $ -w 4-$6-dV0H0X@]y, $,^0*@]yP B6 ^sp_MStablenamefromnick/2t, ]+8:-D c-l(A%^\%,6&sp_dropmergearticle-%<-lG0&%G@publicationu`-%,(6%(@publicationx-%=-?0&%?@articlesX-%- 6% @article-%>-U0&%hhU@ignore_distributore =p-%-66%6@ignore_distributoris|-%?-A0&%hhA@reserved\- % -"6%"@reservedP- % -l%eP- % - %P- % - %varP- % - %\P-% -%rroP-% -% P-% -%SM(T-% -n %T-% - %T-% - %P-% -%!CP-% -%P-% -%W`CF{ -%%4-%R-X0*%P ,6 Xsp_dropmergearticlel-% C*46%4sp_dropmergearticleD-%ZM-l  %-%"0% CREATE PROCEDURE sp_dropmergearticle( @publication sysname, /* The publication name */ @article sysname, /* The article name */ @ignore_distributor bit = 0, @reserved bit = 0 ) AS set nocount on /* ** Declarations. */ declare @db_name sysname declare @cmd nvarchar(255) declare @artid uniqueidentifier declare @objid int declare @pubid uniqueidentifier declare @pubidstr nvarchar(38) declare @merge_pub_object_bit int declare @unpublish_bit int declare @retcode int declare @replinfo int declare @dbname sysname declare @distributor sysname declare @distribdb sysname declare @distproc nvarchar(255) declare @object_name sysname declare @uid smallin declare @owner sysname declare @qualified_name nvarchar(255) declare @filterid int declare @proc_name sysname declare @implicit_transaction int declare @close_cursor_at_commit int declare @sync_objid int declare @view_type int select @close_cursor_at_commit = 0 select @implicit_transaction = 0 /* ** Save setting values first before changing them */ IF (@reserved = 0) BEGIN SELECT @implicit_transaction = @@options & 2 SELECT @cose_cursor_at_commit = @@options & 4 SET IMPLICIT_TRANSACTIONS OFF SET CURSOR_CLOSE_ON_COMMIT OFF END /* ** Initializations. */ -- merge uses bit 8 in replinfo select @merge_pub_object_bit = 128 select @unpublish_bit = ~@merge_pub_object_bit /* ** Security Check */ EXEC @retcode = dbo.sp_MSreplcheck_publish IF @@ERROR <> 0 or @retcode <> 0 return (1) /* ** Check to make sure that this database is enabled for ublishing */ if not exists (select * from sysobjects where name = 'sysmergepublications') BEGIN RAISERROR (20054, 16, -1) RETURN (1) END /* ** Get the @pubid. */ if NOT EXISTS (select * FROM sysmergepublications WHERE name = @publication and UPPER(publisher)=UPPER(@@servername) and publisher_db=db_name()) BEGIN RAISERROR (20026, 16, -1, @publication) RETURN (1) END select pubid = pubid FROM sysmergepublications WHERE name = @publication and UPPER(publisher)=UPPER(@@servername) and publisher_db=db_name() select @db_name = db_name from sysmergesubscriptions where (pubid=@pubid) and (subid=@pubid) IF @db_name <> db_name() BEGIN RAISERROR (20047, 16, -1) RETURN (1) END set @pubidstr = '''' + convert(nchar(36), @pubid) + '''' /* ** Parameter Check: @article. ** If the article is 'all', drop all articles for the specified ** publication (@publication). */ if LOWER(@article) = 'all' BEGIN declare hC CURSOR LOCAL FAST_FORWARD FOR select DISTINCT name FROM sysmergearticles WHERE pubid=@pubid FOR READ ONLY OPEN hC FETCH hC INTO @article WHILE (@@fetch_status <> -1) BEGIN EXECUTE dbo.sp_dropmergearticle @publication, @article, @ignore_distributor = @ignore_distributor, @reserved = 1 FETCH hC INTO @article END CLOSE hC DEALLOCATE hC RETURN (0) END /* ** Parameter Check: @article. ** The @article name must conform to the rules for identifiers. */ if @article IS NULL BEGIN RAISERROR (, aH&/,6SplitNextD- &-lq/enh@stoL-&mL-&-= midL- &'arm L-!&).-w%m- P-" & -4-&,6-V0-%m-0%14043, 16, -1, '@article') RETURN (1) END /* ** Parameter Check: @publication. ** The @publication name must conform to the rules for identifiers. */ if @publication IS NULL BEGIN RAISERROR (14043, 16, -1, '@publication') RETURN (1) END /* ** Ascertain the existence of the article. */ if NOT EXISTS (select * FROM sysmergearticles WHERE name = @article AND pubid = @pubid) BEGIN RAISERROR (20027, 16, -1, @article) RETURN (1) END /* ** Delete article from sysmergearticles and clear publish bit in ** sysobjects. */ begin tran save TRAN dropmergearticle /* ** Retrieve the object id of the underlying table. */ select @sync_objid = sync_objid, @view_type = view_type, @artid = artid, @objid = objid frm sysmergearticles where name = @article AND pubid = @pubid select @replinfo = replinfo, @object_name=name, @owner= user_name(uid) from sysobjects where id = @objid /* ** Remove the corresponding rows from sysmergeschemachange */ DELETE FROM sysmergeschemachange WHERE artid = @artid AND pubid = @pubid if @@ERROR <> 0 goto FAILURE /* ** If this is the last article that refers to the base table, drop the * triggers and stored procs */ if NOT exists (select * from sysmergearticles WHERE artid = @artid AND pubid <> @pubid) begin /* ** Cleanup the triggers and stored procs */ EXECUTE @retcode = dbo.sp_MSarticlecleanup @artid = @artid, @pubid = @pubid if @@ERROR <> 0 OR @retcode <> 0 BEGIN GOTO FAILURE END /* ** Clear thereplication bit in sysobjects. Now merge and transactional level ** uses different replication bit, checking transactional level is not needed. */ select @qualified_name = (QUOTENAME(@owner) + '.' + QUOTENAME(@object_name)) exec @retcode = dbo.sp_replupdateschema @qualified_name if @@ERROR <> 0 OR @retcode <> 0 BEGIN GOTO FAILURE END update sysobjects set replnfo = (replinfo & @unpublish_bit) where id = @objid IF @@ERROR <> 0 goto FAILURE end else begin /* Always drop the article proc's they are not shared among publications */ EXECUTE @retcode = dbo.sp_MSdroparticleprocs @artid = @artid, @pubid = @pubid if @@ERROR <> 0 OR @retcode <> 0 BEGIN GOTO FAILURE END /* If the article's has a temporary ( view type = 2) o a permanent view (view_type = 1 ) drop the sync object */ if (@view_type = 1 OR @view_type = 2) begin declare @viewname sysname select @viewname = sysobjects.name from sysobjects where ObjectProperty (sysobjects.id, 'IsView') = 1 and ObjectProperty (sysobjects.id, 'IsMSShipped') = 1 and sysobjects.id = @sync_objid if @viewname IS NOT NULL begin set @viewname = QUOTENAME(@viewname) exec ('drop view ' + @viewname) if @@ERROR<>0 GOTO FALURE end end end /* ** Remove the row from sysmergearticles. */ DELETE FROM sysmergearticles WHERE artid = @artid AND pubid = @pubid if @@ERROR <> 0 BEGIN GOTO FAILURE END /* delete all the filter components that are defined upon the designated article */ select @filterid = min(join_filterid) from sysmergesubsetfilters where artid = @artid AND pubs, 4 -%%m% 0% id = @pubid while (@filterid is not null) begin select @proc_name = expand_proc from sysmergesubsetfilters where artid = @artid AND pubid = @pubid and join_filterid = @filterid if (@proc_name IS NOT NULL) and exists (select * from sysobjects where name = @proc_name and type = 'P') begin exec ('drop proc ' + @proc_name) IF @@ERROR <> 0 goto FAILURE end delete from sysmergesubsetfilters where artid = @artid AND pubid = @pubid and join_filterid = @filterid IF @@ERROR <> 0 goto FAILURE select @filterid = min(join_filterid) from sysmergesubsetfilters where artid = @artid AND pubid = @pubid end /* ** set the pub type to subset or full as appropriate */ execute @retcode = dbo.sp_MSsubsetpublication @publication if @@ERROR <> 0 or @retcode <> 0 RETURN (1) /* ** 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 FAILRE END SELECT @dbname = DB_NAME() SELECT @distproc = RTRIM(@distributor) + '.' + @distribdb + '.dbo.sp_MSdrop_article' EXECUTE @retcode = @distproc @publisher = @@SERVERNAME, @publisher_db = @dbname, @publication = @publication, @article = @article IF @@ERROR <> 0 or @retcode <>0 BEGIN goto FAILURE 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: RAISERROR (14047, 16, -1, @article) if @@TRANCOUNT > 0 begin ROLLBACK TRANSACTION dropmergearticl COMMIT TRANSACTION end /* ** 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 (1) rP-& % -#P-' %-'P-( %-( P-) %-)4-%,6-e P887`77+h8 x |\ lp 0@hh8\rom MSmerge_genhistory (updlock) if (@@error <> 0) begin goto FAILURE end select @gen = generation from MSmerge_genhistory where guidsrc = @genguid update sysmergearticles set gen_cur = @gen where nickname = @art_nick if (@@error <e U@ -Iri *o  @@plt :-DR-hT'n6 user_transaction -'%t-'R- **%manics XfZUNT4-'n6-(@Q0D\TRANSACTION return (1) ntP,   , P,  0-@(6 grrevL-(7 -% P- ( -* 4-(6-dV0$0XLLP04\ct @cmd = '' while @this_col <= @src_cols begin exec @isset = dboL/ etnd)eea pergeinsci L(ef-D c-(A^`)X6,sp_addmergepublication-)Y- G0&^G@publication`-)$- (6^(@publication-)Z-G0&^G@description`-)$-(6^(@description|-)[-C0&^88 C@retention\-)&-$6^$@retention|-)\-C0&^C@sync_modep\- )'-$6^$@sync_mode- )]- E0&^ E@allow_pushe`- )$- &6^&@allow_push- )^- E0&^ E@allow_pulls`- )$- &6^&@allow_pull-)_- O0&^ O@allow_anonymoush-)$-06^0@allow_anonymous-)`-Y0&^ Y@enabled_for_internett-)(-:6^:@enabled_for_internet-)a-[0&^  [@centralized_conflictsnt-)'-<6^ <@centralized_conflicts-)b-O0&^  O@dynamic_filtersh-))-06^ 0@dynamic_filtersP-) ^eP-) -^P-) -^劖TP-) -^ P-) -^P-) -^T<P-) -^dP-) -^!JoP-) -^W`P-) -^Qh# - )^-!)R-^0*^P ]6 ^sp_addmergepublicationt-")"-,:6^:sp_ddmergepublicationD-#)ZT- ^-$)'0^ create procedure sp_addmergepublication ( @publication sysname, /* Publication name */ @description nvarchar(255)= NULL, /* Publication description */ @retention int = 60, /* Retention period of 60 days */ @sync_mode nvarchar(10) = 'native', /* (bcp)native, (bcp)character */ @allow_push nvarchar(5) = 'true', /* Pulication allows push subscriptions */ @allow_pull nvarchar(5) = 'true', /* Pulication allows pull subscriptions*/ @allow_anonymous nvarchar(5) = 'false', /* Pulication allows anonymous subscriptions */ @enabled_for_internet nvarchar(5) = 'false', /* Pulication is enabled for internet */ @centralized_conflicts nvarchar(5) = 'true', /* Conflict records stored at publisher : true or false */ @dynamic_filters nvarchar(5) = 'false' /* Will publication be filtered on dynamic clause? */ ) as set nocount on /* ** Declarations. */ declare @retcode int /* return code value for procedure execution */ declare @push tinyint /* subscription type is push */ declare @statid tinyint /* status id based on @status */ declare @sync_modeid tinyint /* sync mode id based on @sync_mode */ declare @global tinyint /* subscriber type of loop-back subscription */ declare @db_name sysname /* database name */ declare @srvid int /* Server ID */ declare @nickname int /* replica nickname */ declare @tranpublish_bit smallint /* online publish bit (flag) in sysdatabases */ declare @mergepublish_bit smallint /* merge publish bit (flag) in sysdatabases */ declare @found int /* flag indicating if publication is found */ declare @pubid uniqueidentifier /* Publication identifier */ declare @allow_push_id bit declare @allow_pull_id bit declare @allow_anonymous_id bit declare @dynamic_filters_id bit DECLARE @enabled_for_internet_id bit declare @centralized_conflicts_id bit declare @priority real declare @automatic tinyint declare @false bit declare @true bit declare @distributor sysname declare @distproc nvarchar(255) declare @distribdb sysname declare @distpubid int declar @full int /* ** Initializations */ select @mergepublish_bit = 4 select @tranpublish_bit = 1 select @priority = 100.0 select @automatic = 1 /* Const: synchronization type 'automatic' */ select @true = 1 select @false = 0 select @full = 0 /* Const: publication type 'full' */ /* ** Set the status to unsynced (1) */ select @statid = 1 select @global = 1 select @push = 0 select @db_name = DB_NAME() /* ** Security Check */ EXEC @retcode = dbo.sp_MSreplcheck_publish IF @@ERROR <> 0 or @retcode <> 0 return (1) /* ** Only publisher can call sp_addmergepublication to add its own publications */ if not exists (select * from sysobjects where name = 'sysmergepublications') BEGIN RAISERROR (20054, 16, -1) ETURN (1) END /* ** Parameter Check: @publication. ** The @tH*/]6SplitNextD-& *-r/= @@ablL-'*nL-(*-%ann_fL-)*'t2n -**n-(0create procedure MS_sqlctrs_users --- 1996/08/30 21:49 as select lg.loginname + ' - ' + convert(varchar(30),pr.spid) ,pr.memusage as 'Memory (8K Pages)' -- 2K in 6.5 ,pr.cpu as 'CPU time' ,pr.physical_io ,count(lk.spid) as 'Locks held' ,pr.spid from master.dbo.sysprocesses pr left outer join master.dbo.syslocks lk on pr.spid=lk.spid ,master.dbo.syslogins lg where pr.sid = lg.sid group by lg.loginname ,pr.spid ,pr.memusage ,pr.cpu ,pr.physical_io id0-- Change one parameter of a profile from the MSagent_parameters table create procedure sp_change_agent_parameter( @profile_id int, @parameter_name sysname, @parameter_value nvarchar(255) )AS declare @slash_parameter_name sysname declare @dash_parameter_name sysname declare @retcode int select @parameter_name = RTRIM(@parameter_name) -- Call proc to validate parameter value exec @retcode = bo.sp_MSvalidate_agent_parameter @profile_id = @profile_id, @parameter_name = @parameter_name, @parameter_value = @parameter_value if @retcode <> 0 RETURN(1) select @slash_parameter_name = lower(stuff(@parameter_name, 1, 1, N'/')) select @dash_parameter_name = lower(stuff(@parameter_name, 1, 1, N'-')) IF exists ( select * from msdb..MSagent_parameters where profile_id = @profile_d and (@slash_parameter_name = lower(parameter_name) or @dash_parameter_name = lower(parameter_name))) BEGIN update msdb..MSagent_parameters set value = @parameter_value where profile_id = @profile_id and (@slash_parameter_name = lower(parameter_name) or @dash_parameter_name = lower(parameter_name)) if @@error <> 0 return(1) END @<-+ *-)nx8L-,*)2-"^nn P-- * -4-&*]6-&V0-%)n-+0^@publication name must conform to the rules for identifiers, ** and must not be the keyword 'all'. */ if @publication is NULL begin raiserror (14043, 16, -1, '@publication') return (1) end exec @retcode = dbo.sp_MSreplcheck_name @publication if @@ERROR <> 0 or @retcode <> 0 return(1) if LOWER (@publication) = 'all' begin raiserror (14034, 16, -1) return (1) end /* ** Parameter Check: @retention. ** Make sure that the maximum retention period is 60 days */ if @retention is not NULL and @retention<0 begin raiserror(20050, 16, -1, 0) return(1) end if @retention is NULL select @retention = 0 /* ** Parameter Check: @sync_mode. ** Make sure that the sync_mode is one of the following: ** ** id sync_mode ** == ========== ** 0 (bcp)native ** 1 (bcp)character */ if LOWER(@sync_mode)='portable' select @sync_mode='character' if LOWER(@sync_mode) is NULL OR LOWER(@sync_mode) NOT IN ('bcp native', 'bcp character', 'native', 'character') begin raiserror (20076, 16, -1) return (1) end if LOWER(@sync_mode) = 'native' or LOWER(@sync_mode)='bcp native' select @sync_modeid = 0 else select @sync_modeid = 1 /* ** Parameter Check: @allow_push. */ if @allow_push IS NULL OR LOWER(@allow_push) NOT IN ('true', 'false') BEGIN RAISERROR (14148, 16, -1, '@allow_push') RETURN (1) END if LOWER(@allow_push) = 'tru' select @allow_push_id = 1 else select @allow_push_id = 0 /* ** Parameter Check: @allow_pull. */ if @allow_pull IS NULL OR LOWER(@allow_pull) NOT IN ('true', 'false') BEGIN RAISERROR (14148, 16, -1, '@allow_pull') RETURN (1) END if LOWER(@allow_pull) = 'true' select @allow_pull_id = 1 else select @allow_pull_id = 0 /* ** Parameter Check: @allow_anonymous. */ f @allow_anonymous IS NULL OR LOWER(@allow_anonymous) NOT IN ('true', 'false') BEGIN RAISERROR (14148, 16, -1, '@allow_anonymous') RETURN (1) END if LOWER(@allow_anonymous) = 'true' select @allow_anonymous_id = 1 else select @allow_anonymous_id = 0 /* ** Parameter Check: @enabled_for_internet. */ IF @enabled_for_internet IS NULL OR LOWER(@enabled_for_internet) NOT IN ('true', 'false') BEGIN RAISERROR (14148, 16, -1, '@enabled_for_internet') RETURN (1) END IF LOWER(@enabled_for_internet) = 'true' SELECT @enabled_for_internet_id = 1 ELSE SELECT @enabled_for_internet_id = 0 /* ** Parameter Check: @centralized_conflicts. */ if @centralized_conflicts IS NULL OR LOWER(@centralized_conflicts) NOT IN ('true', 'false') BEGIN RAISERROR (14148, 16, -1, '@centralized_conflicts') RETURN (1) END if LOWER(@centralized_conflicts) = 'true' select @centralized_conflicts_id = 1 else select @centralized_conflicts_id = 0 /* ** Parameter Check: @dynamic_filter. */ IF @dynamic_filters IS NULL OR LOWER(@dynamic_filters) NOT IN ('true', 'false') BEGIN RAISERROR (14148, 16, -1, '@dynamic_filters') RETURN (1) END IF LOWER(@dynamic_filters) = 'true' SELECT @dynamic_filters_id = 1 ELSE SELECT @dynamic_filters_id = 0 /* ** Check to see if the publication name is already used. ** 1. check merge pubs ** 2. check online publications */ d H+/]6SplitNextD-1 +-'s/P@L-2+o0nL-3+n-0oL-4+-*no-5+o-30create procedure MS_sqlctrs_users --- 1996/08/30 21:49 as select lg.loginname + ' - ' + convert(varchar(30),pr.spid) ,pr.memusage as 'Memory (8K Pages)' -- 2K in 6.5 ,pr.cpu as 'CPU time' ,pr.physical_io ,count(lk.spid) as 'Locks held' ,pr.spid from master.dbo.sysprocesses pr left outer join master.dbo.syslocks lk on pr.spid=lk.spid ,maste.dbo.syslogins lg where pr.sid = lg.sid group by lg.loginname ,pr.spid ,pr.memusage ,pr.cpu ,pr.physical_io 60-- Change one parameter of a profile from the MSagent_parameters table create procedure sp_change_agent_parameter( @profile_id int, @parameter_name sysname, @parameter_value nvarchar(255) )AS declare @slash_parameter_name sysname declare @dash_parameter_name sysname declare @retcode int select @paramter_name = RTRIM(@parameter_name) -- Call proc to validate parameter value exec @retcode = dbo.sp_MSvalidate_agent_parameter @profile_id = @profile_id, @parameter_name = @parameter_name, @parameter_value = @parameter_value if @retcode <> 0 RETURN(1) select @slash_parameter_name = lower(stuff(@parameter_name, 1, 1, N'/')) select @dash_parameter_name = lower(stuff(@parameter_name, 1, 1, N'-')) IF exists ( select * from msdb..MSagent_parameters where profile_id = @profile_id and (@slash_parameter_name = lower(parameter_name) or @dash_parameter_name = lower(parameter_name))) BEGIN update msdb..MSagent_parameters set value = @parameter_value where profile_id = @profile_id and (@slash_parameter_name = lower(parameter_name) or @dash_parameter_name = lower(parameter_name)) if @error <> 0 return(1) END <-6 +n-4ox8L-7+)3--ooP-8 + -.4-1+]6-1V0-0)n-70^ if exists (select * from sysmergepublications where name = @publication and UPPER(publisher)=UPPER(@@serername) and publisher_db=db_name()) begin RAISERROR (20025, 16, -1, @publication) RETURN (1) end if (select category & @tranpublish_bit from master..sysdatabases where name = @db_name) <> 0 begin EXEC @retcode = dbo.sp_helppublication @publication, @found output if @@ERROR <> 0 OR @retcode <> 0 BEGIN RETURN (1) END if @found <> 0 BEGIN RAISERROR (20025, 16, -1, @publication) RETURN (1) END end /* ** Add the publication as the designmaster of the replica set. */ /* Generate a guid for the publication ID */ set @pubid = newid() /* Select the server's ID as 0 since this is the LOCAL server */ select @srvid = 0 /* Look for existing nickname from any other subscription */ exec @retcode=sp_MSgetreplnick NULL, NULL , NULL, @nickname out if (@@error <> 0) or @retcode <> 0 begin ETURN(1) end /* Generate a new replica nickname from the @pubid */ if (@nickname is null) begin execute @retcode = dbo.sp_MSgenreplnickname @pubid, @nickname output IF @@ERROR <>0 OR @retcode <> 0 BEGIN RAISERROR (20077, 16, -1) RETURN (1) END end else select @priority=max(priority) from sysmergesubscriptions where db_name=@db_name and srvid = @srvid /* ** A chane in design. */ if @priority = 0 begin RAISERROR(21087, 16, -1) return (1) end /* ** Get distributor information */ EXEC @retcode = dbo.sp_helpdistributor @rpcsrvname = @distributor OUTPUT, @distribdb = @distribdb OUTPUT if @@error <> 0 OR @retcode <> 0 or @distributor IS NULL OR @distribdb IS NULL BEGIN RAISERROR (14071, 16, -1) RETURN (1) END /* ** ad an entry into sysmergepublications */ begin tran save tran sp_addmergepublication /* Add row in the publications table */ insert sysmergepublications (pubid, name, description, designmasterid, retention, parentid, sync_mode, allow_push, allow_pull, allow_anonymous, centralized_conflicts, status, napshot_ready, enabled_for_internet, publication_type, dynamic_filters) values (@pubid, @publication, @description, @pubid, @retention, @pubid, @sync_modeid, @allow_push_id, @allow_pull_id, @allow_anonymous_id, @centralized_conflicts_id, @statid, @false, @enabled_for_intrnet_id, @full, @dynamic_filters_id) if @@ERROR <> 0 begin goto FAILURE end /* Add row to represent reciprocal subscription */ insert sysmergesubscriptions(subid, partnerid, datasource_type, srvid, db_name, status, priority, pubid, subscriber_type, subscription_type, sync_type, login_name) values (@pubid, @pubid, 0, @srvid, @db_name, @statid, @priority, @pubid, @global, @push, @automatic, suser_snme(suser_sid())) if @@ERROR <> 0 begin goto FAILURE end /* ** Add row for merge publication to MSmerge_replinfo. */ insert MSmerge_replinfo(repid, replnickname) values (@pubid, @nickname) sp_H,/]6SplitNext8-<,-V0L-= ,-2t/D-> ,->t/nst@ign8-? ,-x8L-@,p0noL-A,n-;oMEpriL-B,o-6n pRRL-C,)3-8^pn P-D , -94-,]6-<V0 -;)p-A 0^ if @@ERROR <> 0 begin goto FAILURE end /* ** Add the publication to the distributor side */ SELECT @distpubid = @nickname select @distproc = RTRIM(@distributor) + '.' + @distribdb + '.dbo.sp_MSadd_publication' EXECUTE @retcode = @distproc @publisher = @@SERVERNAME, @publisher_db = @db_name, @publication = @publication, --@publication_id = NULL, @publication_type = 2, -- 0 = Trans, 1 = Snapshot, 2 = Merge @independent_agent = @true, @immediate_sync = @true, @allow_push = @allow_push_id, @allow_pull = @allow_pull_id, @allow_anonymous = @allow_anonymous_id, --@snapshot_agent = NULL, --@logreader_agent = NULL, @description = @description, @retention = @retention IF @@ERROR <> 0 or @retcode <> 0 BEGIN GOTO FAILURE END -- Populate the initial list. exec @retcode = dbo.sp_grant_publication_access @publication = @publication, @login = null, @reserved = 'init' IF @@error <> 0 OR @retcode <> 0 GOTO FAILURE commit tran return (0) FAILURE: RAISERROR (14018, 16, -1) /* UNDONE : This code is specific to 6.X nested transaction semantics */ if @@TRANCOUNT > 0 begin ROLLBACK TRANSACTION sp_addmergepublication COMMIT TRANSACTION end return (1) nP-G ) -EP-H )-HP-I )-I P-J )-J 4-)]6-ue \d dclcc(VUUXU UTtT 0 goto FAILURE return FAILURE: if @@trancount > 0 rollback tran raiserror (20041, 16, -1) return ' execute (@c -D c-(A>h/62sp_changemergepublication t-/q'G0&G@publicationd`-/:-(6(@publication|-/q-A0&A@property */\-/:-"6"@propertydet-/q -;0&;@value T-/<-6@valueP-/ - ege P- / -  = P- / - W` ni - /- /R$-d0*P 6 dsp_changemergepublicationx- /T-#@6@sp_changemergepublicationD-/ZZ-$ H0/6SplitNextD- 0-?u/l n@t iL-0qL-0-5teq L-0' enqn,L-0)6-Dq @P- 0 -4-06-V0-/q-0 CREATE PROCEDURE sp_changemergepublication ( @publication sysname, /* Publication name */ @property sysname = NULL, /* The property to change */ @value nvarchar(255) = NULL /* The new property value */ ) AS SET NOCOUNT ON /* ** Declarations. */ declare @cmd nvarchar(255) declare @pubid uniqueidentifier declare @pubidstr nvarchar(38) declare @retcode int declare @retention int declare @statusid tinyint declare @sync_modeid tinyint declare @distributor sysname declare @distproc nvarchar(255) declare @value_bit bit declare @subscribed int declare @dbname sysname declare @distribdb sysname /* ** Initializations */ select @subscribed = 1 /* ** Securit Check */ EXEC @retcode = dbo.sp_MSreplcheck_publish IF @@ERROR <> 0 or @retcode <> 0 return (1) /* ** Check if current DB is enabled for publication/subscription */ if not exists (select * from sysobjects where name = 'sysmergepublications') BEGIN RAISERROR (20054, 16, -1) RETURN (1) END /* ** Parameter Check: @property. ** If the @property parameter is NULL, prit the options. */ if @property IS NULL BEGIN CREATE TABLE #tab1 (properties sysname) INSERT INTO #tab1 VALUES ('description') INSERT INTO #tab1 VALUES ('status') INSERT INTO #tab1 VALUES ('retention') INSERT INTO #tab1 VALUES ('sync_mode') INSERT INTO #tab1 VALUES ('allow_push') INSERT INTO #tab1 VALUES ('allow_pull') INSERT INTO #tab1 VALUES ('allow_anonymous') INSERT INT #tab1 VALUES ('enabled_for_internet') INSERT INTO #tab1 VALUES ('centralized_conflicts') INSERT INTO #tab1 VALUES ('snapshot_ready') select * FROM #tab1 RETURN (0) END if @value is NULL and LOWER(@property) not in ('description', 'retention') begin RAISERROR (20081, 16, -1, @property) RETURN (1) end /* ** Parameter Check: @publication. ** Make sure that the publication exists. */ if @publication IS NULL BEGIN RAISERROR (14043, 16, -1, '@publication') RETURN (1) END select @pubid = pubid FROM sysmergepublications WHERE name = @publication and UPPER(publisher)=UPPER(@@servername) and publisher_db=db_name() set @pubidstr = '''' + convert(nchar(36), @pubid) + '''' if @pubid IS NULL BEGIN RAISERROR (20026, 16, -1, @publication) RETURN (1) END else /* ** Parameter Check: @property. ** Check to make sure that @property is a valid property in ** sysmergepublications. */ if LOWER(@property) NOT IN ('description', 'status', 'retention', 'sync_mode', 'allow_push', 'allow_pull', 'allow_anonymous', 'enabled_for_internet', 'centralized_conflicts', 'snapshot_ready') BEGIN RAISERROR (21053, 16, -1) RETURN (1) END BEGIN TRAN sp_changemergepublication /* ** Cange the property. */ if LOWER(@property) IN ('description') BEGIN UPDATE sysmergepublications SET description = @value WHERE pubid = @pubid if @@ERROR <> 0 GOTO UNDO END if LOWER(@property) = 'status' BEGIN /* ** Check to make sure that we have a valid status. */ if LOWER(@value) NOT IN ('active', 'inactive') BEGIN ah8hT4D|D\eout = case @type when 'binary' then 'varbinary' when 'char' then 'varchar' when 'nchar' then 'nvarchar' when 'datetimn' then 'datetime' when 'decimaln' then 'decimal' when 'floatn' then 'float' when 'intn' then 'int' when 'moneyn' then 'money' when 'numericn' then 'numeric' when 'timestamp' then 'varbinary' when 'bit' then 'tinyint' else @type --for user defined data type which may contain space in between END -- append length or scale and precision if n h Ony  --/q-0 RAISERROR (14012, 16, -1) GOTO UNDO END /* ** Determine the integer value for the status. */ if LOWER(@value) = 'active' select @statusid = 1 else select @statusid = 0 /* ** Update the publication with the new status. */ UPDATE sysmergepublications SET status = @statusid WHERE pubid = @pubid if @@ERROR <> 0 GOTO UNDO /* ** If setting to inactive, allow articles / join filters to be altered, and ** clear the snapshot ready bit as well. */ if @statusid = 0 begin UPDATE sysmergepublications SET snapshot_ready = 0 WHERE pubid = @pubid if @@ERROR <> 0 GOTO UNDO UPDATE sysmergearticles SET status = 1 WHERE pubid = @pubid if @ERROR <> 0 GOTO UNDO end END if LOWER(@property) = 'retention' BEGIN /* ** Update the publication with the new replication frequency. */ select @retention = CONVERT(int, @value) if @retention is NULL select @retention = 0 if @retention < 0 begin raiserror(20050, 16, -1, 0) GOTO UNDO end UPDATE sysmergepublications SET retention = @retentio WHERE pubid = @pubid if @@ERROR <> 0 GOTO UNDO END if LOWER(@property) = 'sync_mode' BEGIN /* ** Check for a valid synchronization method. */ if LOWER(@value) NOT IN ('native', 'character', 'bcp native', 'bcp character') begin raiserror (20076, 16, -1) GOTO UNDO end /* ** Determine the inteer value for the sync_mode. */ if LOWER(@value) IN ('native', 'bcp native') select @sync_modeid = 0 else if LOWER(@value) IN ('character', 'bcp character') select @sync_modeid = 1 /* ** Update the publication with the new synchronization method. */ UPDATE sysmergepublications SET sync_mode = @sync_modeid WHERE pubid = @pubid if @@ERROR<> 0 GOTO UNDO END if LOWER(@property) IN ('allow_push', 'allow_pull', 'allow_anonymous', 'enabled_for_internet', 'centralized_conflicts', 'snapshot_ready') BEGIN /* ** Check for a valid value. */ if LOWER(@value) NOT IN ('true', 'false') BEGIN RAISERROR (14137, 16, -1) GOTO UNDO END /* ** set value bit */ if LOWER(@value) = 'true' select @vale_bit = 1 else select @value_bit = 0 if LOWER(@property) = 'allow_anonymous' BEGIN /* Update the allow_anonymous column */ UPDATE sysmergepublications SET allow_anonymous = @value_bit WHERE pubid = @pubid if @@error <> 0 BEGIN GOTO UNDO END END if LOWER(@property) = 'allow_push' BEGIN /* Update the allow_ush column */ UPDATE sysmergepublications SET allow_push = @value_bit WHERE pubid = @pubid if @@error <> 0 BEGIN GOTO UNDO END END if LOWER(@property) = 'allow_pull' BEGIN /* Update the allow_pull column */ UPDATE sysmergepublications SET allow_pull = @value_bit WHERE pubid = @pubid if @@error <> 0 H1/6SplitNextD- 1-v/@L-1r0qL-1q-e rurL-1-q r L-1)7-rapP- 1 -4-16-V0 -/r- 0 BEGIN GOTO UNDO END END if LOWER(@property) = 'centralized_conflicts' BEGIN /* Update the centralized_conflicts column */ UPDATE sysmergepublications SET centralized_conflicts = @value_bit WHERE pubid = @pubid if @@error <> 0 BEGIN GOTO UNDO END END if LOWER(@property) = 'enabled_for_internet' BEGIN /* Update the enabled_for_internet column */ UPDATE sysmergepublications SET enabled_for_internet = @value_bit WHERE pubid = @pubid if @@error <> 0 BEGIN GOTO UNDO END END if LOWER(@property) = 'snapshot_ready' BEGIN /* Update the allow_anonymous column */ UPDATE sysmergepublications SET snapshot_ready = @value_bit WHERE pubid = @pubid if @@error <> 0 BEGIN GOTO UNDO END END END /* ** Update merge publication property at distributor side if necessaray */ IF LOWER(@property) IN ('description','allow_push', 'allow_pull', 'allow_anonymous','retention') BGIN IF LOWER(@property) IN ('allow_push', 'allow_pull', 'allow_anonymous') /* Translate values */ BEGIN IF LOWER(@value) = 'true' SELECT @value = '1' ELSE IF LOWER(@value) = 'false' SELECT @value = '0' END /* ** Get distribution server information for remote RPC call. */ EXECUTE @retcode = dbo.sp_helpdistributor @rpcsrvname = @istributor OUTPUT, @distribdb = @distribdb OUTPUT IF @@ERROR <> 0 or @retcode <> 0 BEGIN GOTO UNDO END SELECT @dbname = DB_NAME() SELECT @distproc = RTRIM(@distributor) + '.' + @distribdb + '.dbo.sp_MSchange_publication' EXECUTE @retcode = @distproc @publisher = @@SERVERNAME, @publisher_db = @dbname, @publication = @publication, @poperty = @property, @value = @value IF @@ERROR <> 0 OR @retcode <> 0 BEGIN GOTO UNDO END END COMMIT TRAN /* ** Return succeed. */ RAISERROR (14077, 10, -1) RETURN (0) UNDO: IF @@TRANCOUNT = 1 ROLLBACK TRAN ELSE COMMIT TRAN P- / -P- /- P /- P- /- 4-/6- L\Hx,Pmergefilter if exists (select * from sysobjects where type = 'P' and name = 'sp_addmergefilter') drop procedure sp_addmergefilter if exists (select * from sysobjects where type = 'P' -rdE  pu gn@  -DR$- 7T26 user_transaction -2t-2R$- **proc drf_M4-26-(@Q0D\s (select * from sysobjects where type in ('P ') 0-@3\6 grrevrL-3A - P- 3 - 4-3\6-dV0T0Xjects where type in ('P ') and name = 'sp_enumcustomresolvers') "9:-D c-(A> c d46.sp_helpmergepublicationh-4'G0&>G@publicationf`-4-(6>(@publicationt-4-;0&>88 ;@found T-4-6>@found-4-M0&>$$M@publication_id(sh-4-.6>.@publication_id(|-4-A0&>(A@reserved \- 4-"6>"@reserved P- 4 - >(tsP- 4 - >( P- 4 - >') - 4>-4R+-`0*>P 6 `sp_helpmergepublicationt-4B- <6><sp_helpmergepublicationD-4Z`- >-40> CREATE PROCEDURE sp_helpmergepublication ( @publication sysname = '%', /* The publication name */ @found int = NULL OUTPUT, @publication_id uniqueidentifier = NULL OUTPUT, @reserved nvarchar(20) = NULL ) AS SET NOCOUNT ON /* ** Declarations. */ declare @retcode int declare @no_row bit declare @our_srvid int declare @has_subscription bit /* ** Initializations. */ select @has_subscription = 0 if @found is NULL BEGIN select @no_row=0 END else BEGIN select @no_row=1 END select @found = 0 select @our_srvid = max(srvid) from master..sysservers where UPPER(srvname) = UPPER(@@SEVERNAME) /* ** Running sp_help is OK from everywhere, whether enabled for publishing or not */ IF not exists (select * from sysobjects where name='sysmergesubscriptions') RETURN (0) /* ** Parameter Check: @publication. ** Check to make sure that there are some publications ** to display. */ if @publication IS NULL BEGIN RAISERROR (14043, 16, -1, '@publication') RETURN (1) END I LOWER(@reserved) = 'internal' GOTO SelectPubs if NOT EXISTS (select * FROM sysmergepublications pub, sysmergesubscriptions sub WHERE pub.name like @publication and UPPER(pub.publisher)=UPPER(@@servername) and pub.publisher_db=db_name() and sub.pubid = pub.pubid and sub.srvid = @our_srvid and sub.db_name = db_name()) BEGIN select @found = 0 RETURN (0) END ese BEGIN select @found = 1 select @publication_id = pubid FROM sysmergepublications WHERE name = @publication and UPPER(publisher)=UPPER(@@servername) and publisher_db=db_name() if exists (select * from sysmergesubscriptions where pubid<>subid and pubid in (select pubid from sysmergepublications where name like @publication and UPPER(publisher)=UPPER(@@servername) and publisher_db=db_name())) select @has_suscription = 1 if @no_row <> 0 RETURN(0) END SelectPubs: CREATE TABLE #tab1 ( id int identity NOT NULL, name sysname NOT NULL, description nvarchar(255) NULL, status tinyint NOT NULL, retention int NULL, sync_mode tinyint NULL, allw_push int NOT NULL, allow_pull int NOT NULL, allow_anonymous int NOT NULL, centralized_conflicts int NOT NULL, priority float(8) NOT NULL, snapshot_ready tinyint NOT NULL, publication_type int NULL, pubid uniqueidentifier NOT NULL, snapshot_jobid binary(16) NULL, enabled_for_internet int NULL, dynamic_filters int NULL, has_subscription bit NULL ) /* This is valid at all sites - used for decentralized conflicts */ IF LOWER(@reserved) = 'internal' begin INSERT into #tab1(name, description, status, retention, sync_mode, allow_push, allow_pull, allow_anonymous, centralized_conflics, priority, snapshot_ready, publication_type, pubid, snapshot_jobid, enabled_fo H5/6SplitNextD- 5-w/v@eL-5sL-5-is\L-5' $sw-s-0?C  create procedure sp_ddopen; 12( @handle int output, @procname sysname, @scrollopt int output, @ccopt int output, @rows int output, @p1 nvarchar(774), @p2 nvarchar(774), @p3 nvarchar(774), @p4 nvarchar(774), @p5 nvarchar(774)) as set nocount on declare @ret int create table #sptables ( TABLE_QUALIFIER sysname null, TABLE_OWNER sysname nll, TABLE_NAME sysname null, TABLE_TYPE varchar(32) null, REMARKS varchar(254) null) if @procname = 'sp_tables' begin insert into #sptables exec sp_tables @p1,@p2,@p3,@p4 end else begin insert into #sptables exec sp_tables_ex @p1,@p2,@p3,@p4,@p5 end exec @ret = sp_cursoropen @handle output, 'select * from #sptables', @scrollopt output, @ccopt output, @rows output drop table #sptables return @ret 0> CREATE PROCEDURE sp_helpmergepublication ( @publication sysname = '%', /* The publication name */ @found int = NULL OUTPUT, @publication_id uniqueidentifier = NULL OUTPUT, @reserved nvarchar(20) = NULL ) AS SET NOCOUNT ON /* ** Declarations. */ declare @retcode int declare @no_row bit declare @our_srvid int declare @has_subscription bit /* ** Initializations. */ select @has_subscription = 0 if @found is NULL BEGIN select @no_row=0 END else BEGIN select @no_row=1 END select @found = 0 select @our_srvid = max(srvid) from master..sysservers where UPPER(srvname) = UPPER(@@SERVERNAME) /* ** Running sp_help is OK from everywhere, whether enabled for publishing or not */ IF not exists (select * from sysobjects where name='sysmergesubscriptions') RETURN (0) /* ** Parameter Check: @pubication. ** Check to make sure that there are some publications ** to display. */ if @publication IS NULL BEGIN RAISERROR (14043, 16, -1, '@publication') RETURN (1) END IF LOWER(@reserved) = 'internal' GOTO SelectPubs if NOT EXISTS (select * FROM sysmergepublications pub, sysmergesubscriptions sub WHERE pub.name like @publication and UPPER(pub.publisher)=UPPER(@@servername) an pub.publisher_db=db_name() and sub.pubid = pub.pubid and sub.srvid = @our_srvid and sub.db_name = db_name()) BEGIN select @found = 0 RETURN (0) END else BEGIN select @found = 1 select @publication_id = pubid FROM sysmergepublications WHERE name = @publication and UPPER(publisher)=UPPER(@@servername) and publisher_db=db_name() if exists (select * fro sysmergesubscriptions where pubid<>subid and pubid in (select pubid from sysmergepublications where name like @publication and UPPER(publisher)=UPPER(@@servername) and publisher_db=db_name())) select @has_subscription = 1 if @no_row <> 0 RETURN(0) END SelectPubs: CREATE TABLE #tab1 ( id int identity NOT NULL, name sysname NOT NULL, description nvarchar(255) NULL, status tinyint NOT NULL, retention int NULL, sync_mode tinyint NULL, allow_push int NOT NULL, allow_pull int NOT NULL, allow_anonymous int NOT NULL, centralized_conflicts int NOT NULL, priority float(8) NOT NULL, snapshot_ready tinyint NOT NULL, publication_type int NULL, pubid uniqueidentifier NOT NULL, snapshot_jobid binary(16) NULL, enabled_for_internet int NULL, dynamic_filters int NULL, has_subscription bit NULL ) /* This is valid at all sites - used fo decentralized conflicts */ IF LOWER(@reserved) = 'internal' begin INSERT into #tab1(name, description, status, retention, sync_mode, allow_push, allow_pull, allow_anonymous, centralized_conflicts, priority, snapshot_ready, publication_type, pubid, snapshot_jobid, enabled_foes<- 5-sLx8L-5)=-?C seP 5 -4-56-V0 -4s-m 0>m r_internet, dynamic_filters) select pubs.name, pubs.description, pubs.status, pubs.retention, pubs.sync_mode, pubs.allow_push, pubs.allow_pull, pubs.allow_anonymous, pubs.centralized_conflicts, subs.priority, pubs.snapshot_ready, pubs.publicaion_type, pubs.pubid, replinfo.snapshot_jobid, pubs.enabled_for_internet, pubs.dynamic_filters FROM sysmergesubscriptions subs, sysmergepublications pubs, MSmerge_replinfo replinfo WHERE pubs.name LIKE @publication AND UPPER(pubs.publisher)=UPPER(@@servername) AND pubs.publisher_db=db_name() AND subs.subid = pubs.pbid AND replinfo.repid = pubs.pubid AND subs.subscriber_type = 1 ORDER BY name end /* This is valid only at publishers and republishers */ else begin INSERT into #tab1(name, description, status, retention, sync_mode, allow_push, allow_pull, allow_anonymous, centralized_conflicts, priority, snapshot_ready, publication_type, pubid, snapshot_jobid, enabled_for_internet, dynamic_filters, has_subscription) select pubs.name, pubs.description, pubs.status, pubs.retention, pubs.sync_mode, pubs.allow_push, pubs.allow_pull, pubs.allow_anonymous, pubs.centralized_conflicts, subs.priority, pubs.snapshot_ready, pubs.publication_type, pubs.pubid, replinfo.snapshot_jobid, pubs.enabled_for_internet, pubs.dynamic_filters, case when exists (select * from sysmergesubscritions where pubid<>subid and pubid in (select in_pubs.pubid from sysmergepublications in_pubs where in_pubs.name = pubs.name and UPPER(in_pubs.publisher)=UPPER(@@servername) and in_pubs.publisher_db=db_name())) then 1 else 0 end FROM sysmergesubscriptions subs, sysmergepublications pubs, MSmerge_replinfo replinfo WHERE pubs.nme LIKE @publication and UPPER(pubs.publisher)=UPPER(@@servername) and pubs.publisher_db=db_name() AND subs.subid = pubs.pubid AND replinfo.repid = pubs.pubid AND subs.subscriber_type = 1 AND subs.srvid = @our_srvid AND subs.db_name = db_name() ORDER BY name end if @@ERROR <> 0 RETURN (1) elect * FROM #tab1 RETURN (0) P- 4 -P- 4-P- 4- P- 4- 4-46- h998x8(8,L,++t+X L@ 0Xh@\ sap ut-r mdl u5t oblFR l:-DR+-/T6=6 user_transaction -6>t-6R+- **> ` bTU4-6=6-(@Q0D\ (0) tP,(  ,&P,) 0-@76 grrevL-7E -> P- 7 -! 4-76-dV050X$  4D<4Dd| D\at does not set PK cols -- only do this if the article contains columns that are not included -- in the pk if @artcolumns != @pkcolut,i6,4KL-D c-(A c B d8#6.sp_dropmergepublication-8#- G0& c G@publication`-8- (6 c (@publication-8$-U0& c hhU@ignore_distributorp-8-66 c 6@ignore_distributor|-8%-A0& c hhA@reserved\-8-"6 c "@reserved P-8 -  c e P- 8 -  c P- 8 -  c %P- 8 -  c nP- 8 -  c W` - 8 c -8R2-`0* c P #6 `sp_dropmergepublicationt-8 D-<6 c <sp_dropmergepublicationD-8Zg-  c H9/#6SplitNextD- 9-x/@L-9tL-9-MtQL-9't@-9-0q  CREATE PROCEDURE sp_createstats @indexonly CHAR(9)= 'NO', -- Optional 'INDEXONLY' text - if present, then only the columns -- covered by indexes are subject of statistics creation @fullscan CHAR(9)= 'NO', -- Optional 'FULLSCAN' text - if present, then the statistics -- will be updated with full scan rather than sampling @norecompute CHAR(12)= 'NO' -- Optional 'NORECOMPUTE' text - if present, then statistics -- willnot be updated automatically AS /* NOTE: This sp will update statistics for *all* columns of all tables which the user has the privilege to update stats on (sysadmin, dbo, owner). The following columns are not considered - first column of an index - column which already has statistics - unelligible columns (Text and image columns consisting of ntext, text, or image data type, bit, and computed columns) */ declare @sysadmin int ,@dbname sysname -- remember if the user is sysdmin SELECT @sysadmin = is_srvrolemember('sysadmin'), @dbname = db_name() -- create temporary table (column, index position) create table #colpostab ( col_name sysname, col_pos int, ) set nocount on DECLARE @exec_stmt nvarchar(540) DECLARE @tablename sysname DECLARE @columnname sysname --DECLARE @shortcolumnname sysname DECLARE @indexname sysname DECLARE @uid smallint DECLARE @indid smallint DECLARE @position smallint DECLARE @table_id int DECLARE @user_name sysname DELARE @numcols int -- number of eligible columns found DECLARE @msg nvarchar(386) DECLARE @timestamp varchar(17) DECLARE @tablename_header varchar(267) DECLARE tnames_cursor INSENSITIVE CURSOR FOR SELECT name, id, uid FROM sysobjects WHERE type = 'U' and ((object_id('[#colpostab]') is NULL) OR (id <> object_id('[#colpostab]'))) SELECT @numcols = 0 OPEN tnames_cursor FETCH NEXT FROM tnames_cursor INTO @tablename, @table_id, @uid WHILE (@@fetch_status <> -1) BEGIN IF ((@@fetch_status < -2) AND ((@sysadmin = 1) OR (user_id() = @uid))) BEGIN -- these are all columns for which the statistics will be updated DECLARE cnames_cursor CURSOR FOR SELECT c.name FROM syscolumns c, systypes t WHERE c.id = @table_id AND c.xtype = t.xusertype AND (t.name NOT IN ('text', 'ntext', 'image', 'timestamp','bit')) AND ((c.colstat & 0x0004) <> 0x0004) AND (c.length<=900) AND c.name NOT IN (SELECT col_name FROM #colpostab WHERE col_pos = 1) AND ((c.name IN (SELECT col_nameFROM #colpostab)) OR (@indexonly <> 'indexonly')) -- populate temporary table of all (column, index position) tuples for this table TRUNCATE TABLE #colpostab -- for each index on the table, loop though all columns and insert rows -- OPEN CURSOR OVER INDEXES DECLARE ind_curs INSENSITIVE CURSOR FOR SELECT indid, name FROM sysindexes where id = @table_id and indid > 0 and indid < 255 order by indid OPEN ind_curs FETCH ind_curs into @indid , @indexname -- IFAN INDEX EXISTS WHILE @@fetch_status >= 0 BEGIN -- Every index has at least one column at position 1 INSERT INTO #colpostab VALUES (index_col(@tablename,@indid,1),1) -- now try position 2 and beyond.... SELECT @columnname = index_col(@tablename, @indid, 2) SELECT @position = 2 WHILE (@columnname is not null ) BEGIN INSERT INTO #colpostab VALUES (@columnname,@position) SELECT @position = @position +1 SELECT @columnname = index_col(@tablename, @indid, position) END -- Next Index FETCH ind_curs into @indid , @indexname END CLOSE ind_curs DEALLOCATE ind_curs -- now go over all columns which are eligible for updating statistics -- and are not first columns of any index -- optionaly we test if they are covered by some index (as non-leading) SELECT @user_name = user_name(@uid) OPEN cnames_cursor FETCH NEXT FROM cnames_cursor INTO @columnname IF @@fetch_stat<- 9-tx8L-9)?- c tP- 9 -4-9#6-V0-8t-0 c  CREATE PROCEDURE sp_dropmergepublication( @publication sysname, /* The publication name */ @ignore_distributor bit = 0, @reserved bit = 0 ) AS set nocount on /* ** Declarations. */ declare @pubid uniqueidentifier declare @article sysname declare @cmd nvarchar(255) declare @retcode int declare @distproc nvarchar(255) declare @distributor sysname declare @distribdb sysname declare @working_dir varchar(255) declare @working_dir_drive varchar(255) declare @pub_dir nvarchar(255) declare @db_name sysname declare @implicit_transaction int declare @close_cursor_at_commit int select @close_cursor_at_commit = 0 select @implicit_transaction = 0 /* ** Save setting values first before changing them */ IF (@reserved = 0) BEGIN SELECT @implicit_transaction = @@options & 2 SELECT @close_cursor_at_commit = @@options & 4 SET IMPLICIT_TRANSACTIONS OFF SET CURSOR_CLOSE_ON_COMMIT OFF END /* ** Initializations. */ select @db_name = db_name() /* ** Security Check */ EXEC @retcode = dbo.sp_MSreplcheck_publish IF @@ERROR <> 0 or @retcode <> 0 return (1) if not exists (select * from sysobjects where name = 'sysmergepublications') BEGIN RAISERROR (20054, 16, -1) RETURN (1) END if LOWER(@publication) = 'all' BEGIN declare hC1 CURSOR LOCAL FAST_FORWARD FOR select DISTINCT name FROM sysmergepublications where UPPE(publisher)=UPPER(@@SERVERNAME) and publisher_db=db_name() FOR READ ONLY OPEN hC1 FETCH hC1 INTO @publication WHILE (@@fetch_status <> -1) BEGIN EXECUTE dbo.sp_dropmergepublication @publication=@publication, @ignore_distributor = @ignore_distributor, @reserved = 1 FETCH hC1 INTO @publication END CLOSE hC1 DEALLOCATE hC1 RETURN (0) END if @publication IS NULL BEGIN RAISERROR (14003, 16, -1) RETURN (1) END /* ** Get the @pubid. */ if NOT EXISTS (select * FROM sysmergepublications WHERE name = @publication and UPPER(publisher)=UPPER(@@servername) and publisher_db=db_name()) BEGIN RAISERROR (20026, 16, -1, @publication) RETURN (1) END seect @pubid = pubid FROM sysmergepublications WHERE name = @publication and UPPER(publisher)=UPPER(@@servername) and publisher_db=db_name() /* ** Ignore external publications */ if exists (select * from sysmergesubscriptions where subid=@pubid and pubid=@pubid and db_name<>db_name()) RETURN (0) /* ** Check to make sure that there are push or pull subscriptions on the publication. */ if EXISTS (select * FROM sysmergesubscriptions sub, sysmergepublications pubs, MSmerge_replinfo repinfo WHERE pubs.name = @publication AND UPPER(pubs.publisher)=UPPER(@@servername) AND pubs.publisher_db=db_name() AND subs.pubid = pubs.pubid AND subs.status <> 2 -- Having a deleted subscription row is fine AND repinfo.repid <> @pubid AD subs.subid <> subs.partnerid) BEGIN RAISERROR (14005, 16, -1) RETURN (1) END begin tran save TRANSACTION dropmergepublication /* ** Dele0 H:/#6SplitNextD- :-y/ -@ imL-:u0tL-:t-UsuL- :-tu-!:u-0q  CREATE PROCEDURE sp_createstats @indexonly CHAR(9)= 'NO', -- Optional 'INDEXONLY' text - if present, then only the columns -- covered by indexes are subject of statistics creation @fullscan CHAR(9)= 'NO', -- Optional 'FULLSCAN' text - if present, then the statistics -- will be updated with full scan rather than sampling @norecompute CHR(12)= 'NO' -- Optional 'NORECOMPUTE' text - if present, then statistics -- will not be updated automatically AS /* NOTE: This sp will update statistics for *all* columns of all tables which the user has the privilege to update stats on (sysadmin, dbo, owner). The following columns are not considered - first column of an index - column which already has statistics - unelligible columns (Text and image columns consisting of ntext, text, or image data type, bit, and computed clumns) */ declare @sysadmin int ,@dbname sysname -- remember if the user is sysadmin SELECT @sysadmin = is_srvrolemember('sysadmin'), @dbname = db_name() -- create temporary table (column, index position) create table #colpostab ( col_name sysname, col_pos int, ) set nocount on DECLARE @exec_stmt nvarchar(540) DECLARE @tablename sysname DECLARE @columnname sysname --DECLARE @shortcolumnname sysname DECLARE @indexname sysname DECLARE @uid smallint DECLARE @indid mallint DECLARE @position smallint DECLARE @table_id int DECLARE @user_name sysname DECLARE @numcols int -- number of eligible columns found DECLARE @msg nvarchar(386) DECLARE @timestamp varchar(17) DECLARE @tablename_header varchar(267) DECLARE tnames_cursor INSENSITIVE CURSOR FOR SELECT name, id, uid FROM sysobjects WHERE type = 'U' and ((object_id('[#colpostab]') is NULL) OR (id <> object_id('[#colpostab]'))) SELECT @numcols = 0 OPEN tnames_cursor FETCH NEXT FROM tnames_cursor ITO @tablename, @table_id, @uid WHILE (@@fetch_status <> -1) BEGIN IF ((@@fetch_status <> -2) AND ((@sysadmin = 1) OR (user_id() = @uid))) BEGIN -- these are all columns for which the statistics will be updated DECLARE cnames_cursor CURSOR FOR SELECT c.name FROM syscolumns c, systypes t WHERE c.id = @table_id AND c.xtype = t.xusertype AND (t.name NOT IN ('text', 'ntext', 'image', 'timestamp','bit')) AND ((c.colstat & 0x0004) <> 0x0004) AND (c.length<=900) AND c.name NOTIN (SELECT col_name FROM #colpostab WHERE col_pos = 1) AND ((c.name IN (SELECT col_name FROM #colpostab)) OR (@indexonly <> 'indexonly')) -- populate temporary table of all (column, index position) tuples for this table TRUNCATE TABLE #colpostab -- for each index on the table, loop though all columns and insert rows -- OPEN CURSOR OVER INDEXES DECLARE ind_curs INSENSITIVE CURSOR FOR SELECT indid, name FROM sysindexes where id = @table_id and indid > 0 and indid < 25 order by indid OPEN ind_curs FETCH ind_curs into @indid , @indexname -- IF AN INDEX EXISTS WHILE @@fetch_status >= 0 BEGIN -- Every index has at least one column at position 1 INSERT INTO #colpostab VALUES (index_col(@tablename,@indid,1),1) -- now try position 2 and beyond.... SELECT @columnname = index_col(@tablename, @indid, 2) SELECT @position = 2 WHILE (@columnname is not null ) BEGIN INSERT INTO #colpostab VALUES (@columnname,@position) SELECT @position = @position +1 SELECT @columnname = index_col(@tablename, @indid, @position) END -- Next Index FETCH ind_curs into @indid , @indexname END CLOSE ind_curs DEALLOCATE ind_curs -- now go over all columns which are eligible for updating statistics -- and are not first columns of any index -- optionaly we test if they are covered by some index (as non-leading) SELECT @user_name = user_name(@uid) OPEN cnames_cursor FETCH NEXT FROM names_cursor INTO @columnname IF @@fetch_stat<-" :t- ux8L-#:)@-q uP-$ : -4-:#6-V0(-8t-# 0 c  te all articles from the publication. */ EXECUTE @retcode = dbo.sp_dropmergearticle @publication = @publiation, @article = 'all', @ignore_distributor = @ignore_distributor if @@ERROR <> 0 OR @retcode <> 0 begin RAISERROR (20040, 16, -1, @publication) goto FAILURE end /* ** Delete sync task of Publication. */ execute @retcode = dbo.sp_MSdropmergepub_snapshot @publication = @publication, @ignore_distributor = @ignore_distributor if @@ERROR <> 0 OR @retcode <> 0 begin RAISERROR (20010, 16, -1, publication) goto FAILURE end /* ** Remove my own subscription from sysmergesubscriptions. */ if exists (select * from sysmergesubscriptions where subid = @pubid) begin DELETE from sysmergesubscriptions WHERE subid = @pubid if @@ERROR <> 0 goto FAILURE end if exists (select * from MSmerge_replinfo where repid = @pubid) begin DELETE from MSmerge_replinfo WHERE repid @pubid if @@ERROR <> 0 goto FAILURE 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. */ EXEC @retcode = dbo.sp_helpdistributor @rpcsrvname = @distributor OUTPUT, @distribdb = @distribdb OUTPUT, @directory = @working_dir OUTPUT IF @@ERROR <> 0 OR @retcode <> 0 BEGIN RAISERROR (14071, 16, -1) goto FAILURE END /* ** Drop the publication info from the distributor */ select @distproc = RTRIM(@distributor) + '.' + @distribdb + '.dbo.sp_MSdrop_publication' EXECUTE @retcode = @distproc @publisher = @@SERVERNAME, @publisher_db =@db_name, @publication = @publication if @@ERROR <> 0 OR @retcode <> 0 begin goto FAILURE end end /* ** Remove the corresponding rows from sysmergeschemachange */ DELETE FROM sysmergeschemachange WHERE pubid = @pubid if @@ERROR <> 0 goto FAILURE /* ** Delete publication from sysmergepublications. */ DELETE FROM sysmergepublications WHERE name = @publication an UPPER(publisher)=UPPER(@@servername) and publisher_db=db_name() if @@ERROR <> 0 goto FAILURE COMMIT TRANSACTION /* ** 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: RAISERROR (14006, 16, -1) /* UNDONE : This code is specific to 6.X nested transaction semantics */ if @@TRANCOUNT > 0 begin ROLLBACK TRANSACTION dropmergepublication COMMIT TRANSACTION end /* ** 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 (1) P-' 8 -%P-( 8-(P-) 8-) P-* 8-*4-8#6-atoJXJJIhI@; ;:p:4:D*))`))(`Px4(hx0@\@@publisher_security_mode6U] &@subscribere 6U] ,@subscriber_db6U] 2@subscr d =@cc 5 NsoANsl R @ >Ca tL-?DR2-7T;i6 user_transaction -?; c t-?;R2-? ** c re `b"4-?;i6-?(@Q0D\~1@dbname6yQ$@owner_sid6yQ(@publication6yQ$@p0-@@<6 grreveL-@<I - c  P-@ < -+ 4-@<6-@dV0e0Xr256L"@loginameDE6ݓ&@profile_idds6E(@publication6E$@publisher6E*@publisher_dber6E-AD c-(AB {| h=J64sp_reinitmergesubscription-A=L-G0&B G@publication`-A=(`(6B (@publication-A=M-AE0&B E@subscriber`-A=-A&6B &@subscriber-A=N-AK0&B K@subscriber_dbd-A=-A,6B ,@subscriber_dbP-A= - B W` -A =B -A =R9?f0*B P J6 fsp_reinitmergesubscription|-A =]O, B6B Bsp_reinitmergesubscriptionAD-A =Zn- B  -A =-! 0B  create procedure sp_reinitmergesubscription @publication sysname = 'all', @subscriber sysname = 'al', @subscriber_db sysname = 'all' AS declare @pubid uniqueidentifier declare @subid uniqueidentifier declare @subscription_type int declare @reinit_bit int declare @publisher sysname declare @publisher_db sysname declare @distribdb sysname declare @distributor sysname declare @distproc nvarchar(255) declare @retcode int /* ** Replace 'all' with '%' */ if LOWER(@publication) = 'al' SELECT @publication = '%' if LOWER(@subscriber) = 'all' SELECT @subscriber = '%' if LOWER(@subscriber_db) = 'all' SELECT @subscriber_db = '%' /* ** At publisher side, publication name is unique */ IF NOT EXISTS (SELECT * FROM sysmergepublications WHERE name LIKE @publication) BEGIN IF @publication = '%' RAISERROR (14008, 11, -1) ELSE RAISERROR (20026, 11, -1, @publication) RETURN (1) END EXECUTE @retcode = dbo.sp_helpdistributor @rpcsrvname = @distributor OUTPUT, @distribdb = @distribdb OUTPUT IF @@ERROR <> 0 or @retcode <> 0 return (1) SELECT @distproc = RTRIM(@distributor) + '.' + RTRIM(@distribdb) + '.dbo.sp_MSmarkreinit ' BEGIN TRAN Declare SYN_CUR CURSOR LOCAL FAST_FORWARD FOR select subs.subid, subs.subscription_type, pubs.publisher, pubs.publisher_db from sysmergepublications pubs, ssmergesubscriptions subs where pubs.name LIKE @publication and UPPER(pubs.publisher)=UPPER(@@servername) and pubs.publisher_db=db_name() AND pubs.pubid=subs.pubid AND subs.pubid<>subs.subid AND db_name like @subscriber_db AND srvid in (select srvid from master..sysservers where ((@subscriber = N'%') or (UPPER(srvname) = UPPER(@subscriber)))) FOR READ ONLY open SYN_CUR fetch SYN_CUR into @subid, @subscription_type, @publisher, @publisher_db while (@@fetch_status<>-1) BEGIN if @subscription_type = 0 update MSmerge_replinfo set schemaversion=0, recgen = NULL, recguid=NULL, sentgen=NULL, sentguid = NULL where repid=@subid and schemaversion is NOT NULL else update MSmerge_replinfo set schemaversion= -1, recgen = NULL, recguid=NULL, sentgen=NULL, sentguid = NULL where repid=@subidand schemaversion is NOT NULL -- 0 for push and -1 for pull exec @distproc @publisher, @publisher_db, @publication, @subscriber, @subscriber_db, 1 if @@ERROR<>0 BEGIN goto Failure END fetch next from SYN_CUR into @subid, @subscription_type, @publisher, @publisher_db END close SYN_CUR deallocate SYN_CUR commit TRAN return (0) Failure: close SYN_CUR deallocate SYN_CUR if @@TRANCOUN = 1 ROLLBACK TRAN else COMMIT TRAN return (1) P-A = -@P-A =-AP-A =-A P-A =-A4-A=J6-ÁCJ0DT<|l$D\rgeaT y ll--KDR9-A T>6 user_transaction -K>B t-K>R9-K **B  fh4-K>6-K(@Q0D\H,fL,I)+ AAf#*-LD c-A(A{| p \?>6(sp_MSpublicationview-L?(% G0&{| G@publication `-L?8-A(6{| (@publication-L?-LE0&{| 88 E@force_flag `-L?8-L&6{| &@force_flagchP-L?  -A {|  P-L?  -L{| oatuP-L?  -L{|  H@/>6SplitNextD-L  @ -/ nv@rchL-L@ L-L @ -L reopL-L @ (4 /*-L@ -L %SM(eso%W`ecl%e lar9 O y-iony-db y- ysny-ectb(ameb( ^ ^on_^  ^Qh# ^T<are^劖T ^W`nc_^d ^e ^!Jo     lar  it   umn  " ^t5) ^td   "  "cla "   "decWӞ:old dW` ere 0)  0)  de0)  0) cla9K ; ?Cre ?Cvfa ?CEcla?C ?CBdre ?C ?Cinam?Came?Ck ?C d?CD P>(/* >(ns iM@stiM siM =iMbseiM Co$S . 'sxgt  @m c  = c p_r c %SQL c W`re  c eif q  q  q r =q sysq jecq  q own]w  ]w  ]w 402]w  jec]w  ]w  B W`  ame ]w own\ %(@s\ % \ -Che\ -@re\ -che\ h  ERR\ h > 0\ :]  \ :]ter\ s ^\ s ^ \ s ^\ s ^{| bli{| ULL{| othe ent   tio  gin or Ͽ licϿ retϿ  Ͽ  ubiϿ ati ameϿ PPEϿ serMޅ r_dMޅ pubMޅ egiMޅ rorMޅ licMޅ etuMޅ  Mޅ ishMޅ &geaMޅ &XECMޅ !cheMޅ ! Mޅ !@re٥ BEG٥  RRO   .  $S  se ]w  fr d = ?||_na\D id \D n z ! (1z !iedz !etuz ! <-L @ -L x8P-L@ + %SM(ISP-L @-A 4-L @>6-L V0P-L ?q L{| ginP-L?s -L{| TURP-L?s -L{|  toP-L?v -L{| xټqentP-L?u -L{| djecP-L?u -L{| N200P-L?u -L{| 5ISre -L?{| 4-L?R@-KZ0*{| P B6 Zsp_MSpublicationviews p-L?YO,66{| 6sp_MSpublicationviewd_D-L?Zu-A  {| HA/B6SplitNextD-L A-L z/nam@) L-L AvL-L!A' vhaL-L"A(ysvubLt0, l|,X@hx8\ if not exists (select * from syscolumns c where c.id=@objid and ColumnProperty(c.id, c.name, 'isrowguidcol') = 1) begin raiserror(20085-? "gh-Z-L#Av-L!A0 create procedure sp_helptrigger --- 1997/06/24 @tabname nvarchar(776), /* Table name */ @triggertype char(6) = NULL /* Trigger type */ as declare @objid int, /* id of the object */ @dbname sysname, @deltrig int, @instrig int, @updtrig int -- Check to see that the object names are local to the current database. select @dbname = parsename(@tabname,3) if @dbname is not null and @dbname <> db_name() begin raiserror(15250,-1,-1) return (1) end select @objid = id from sysobjects where id = object_id(@tabname) and type in ('S','U') if @objid is null begin select @dbname = db_name() raiserror(15009,-1,-1,@tabname,@dbname) return(1) end /* Check that input type is UPDATE, INSERT, DELETE */ if @triggertype is not null and not UPPER(@triggertype ) in ('UPDATE', 'INSERT', 'DELETE') begin raiserror(15305,-1,-1) return(1) end if @triggertype is NULL select trigger_name = name, trigger_owner = user_name(uid), isupdate = ObjectProperty( id, 'ExecIsUpdateTrigger'), isdelete = ObjectProperty( id, 'ExecIsDeleteTrigger'), isinsert = ObjectProperty( id, 'ExecIsInsertTrigger') from sysobjects where parent_obj = @objid and type = 'TR' else begin set @deltrig = case when upper(@triggertype ) = 'DELETE' then 0 else -1 end set @instrig = case when upper(@triggertype ) = 'INSERT' then 0 else -1 end set @updtrig = case when upper(@triggertype ) = 'UPDATE' then 0 else -1 end select trigger_name = name, trigger_owner = user_name(uid), isupdate = ObjectProperty( id, 'ExecIsUpdateTrigger'), isdelete = ObjectProperty( id, 'ExecIsDeleteTrigger'), isinsert = ObjectProperty( id, 'ExecIsInsertTrigger') from sysobjects where parent_obj = @objid and ObjectProperty( id, 'ExecIsDeleteTrigger') > @deltrig and ObjectProperty( id, 'ExecIsInsertTrigger') > @instrig and ObjectProperty( id, 'ExecIsUpdateTrigger') > @updtrig and type = 'TR' end return(0) --sp_helptrigger 0 Acreate procedure sp_MSenum_misc_agents as SET NOCOUNT ON declare @timestamp timestamp -- Not supported, but returned to be consistent with other sp_MSenum_replication_agent -- result set. set @timestamp = 0 select j.name, 'agent_type' = c.name, 'status' = case isnull(jh.run_status, 5) -- mapped to never run when 0 then 6 -- Fail mapping when 1 then 2 -- Success mapping when 2 then 5 -- Retry mapping when 3 then 2 -- Shutdown mapping when 4 then 3 -- Inprogress mapping when 5 then 0 -- Unknown is mapped to never run end, jh.message, 'start_time' = convert(nvarchar(8), jh.run_date) + N' ' + stuff(stuff(right(convert(nvarchar(7), jh.run_time + 1000000) 6), 5, 0, N':'), 3, 0, N':') + + N'.000', jh.run_duration, 'job_id' = convert(binary(16), j.job_id), 'local_timestamp' = @timestamp from msdb..sysjobs j LEFT OUTER JOIN msdb..sysjobhistory jh ON j.job_id = jh.job_id and jh.step_id = 1 and jh.instance_id = (select max(instance_id) from msdb..sysjobhistory jh2 where jh2.job_id = j.job_id and jh2.step_id 1) INNER JOIN msdb..syscategories c ON j.category_id = c.category_id where j.category_id in (11, 12,16,17,18) order by j.job_id asc <-Z A-L"vhx8L-ZA)D-$ vP-Z A -L4-LAB6-LV0-L?-Z0|  CREATE PROCEDURE sp_MSpublicationview( @publication sysname, @force_flag int = 0 ) AS declare @pubid uniqueidentifier declare @artid uniqueidentifier declare @join_articlename nvarchar(270) declare @join_viewname nvarchar(270) declare @article sysname declare @art_nick int declare @join_nick int declare @join_filterclause nvarchar(2000) declare @bool_filterclause nvarchar(2000) declare @view_rule nvarchar(2000) declare @article_level int declare @progress int declare @art int declare @viewname nvarchar(270) declare @procname nvarchar(290) declare @source_objid int declare @source_object nvarchar(258) declare @sync_objid int declare @permanent int decare @temporary int declare @filter_id int declare @filter_id_str nvarchar(10) declare @guidstr nvarchar(40) declare @pubidstr nvarchar(40) declare @rgcol sysname declare @view_type int declare @belongsname sysname declare @join_nickstr nvarchar(10) declare @unqual_jointable sysname declare @retcode smallint declare @hasguid int dclare @join_unique_key int declare @simple_join_view int declare @join_filterid int declare @allhaveguids int declare @command nvarchar(4000) declare @objid int declare @owner sysname declare @table sysname declare @quoted_view nvarchar(290) declare @quoted_pub nvarchar(290) declare @quoted_proc nvarchar(290) declare @snapshot_ready int set @progress = 1 set @article_level = 0 set @permanent = 1 set @temporary = 2 set @allhaveguids = 1 /* ** Only legal publisher can run this stored procedure */ if not exists (select * from sysobjects where name = 'sysmergepublications') BEGIN RAISERROR (20054, 16, -1) RETURN (1) END select @pubid = pubid, @snapshot_ready = snapshot_ready FROM sysmergepublications WHERE name = @pulication and UPPER(publisher)=UPPER(@@servername) and publisher_db=db_name() IF @pubid IS NULL BEGIN RAISERROR (20026, 11, -1, @publication) RETURN (1) END -- If snapshot is already ready, views are good. Don't drop and recreate as someone -- might be using them. if @snapshot_ready = 1 and @force_flag = 0 return (0) exec @retcode = dbo.sp_MSguidtostr @pubid, @pubidstr out if @@ERROR <>0 OR @retcode <>0 return (1) creat table #art(indexcol int identity NOT NULL, art_nick int NOT NULL, article_level int NOT NULL) if @@ERROR <> 0 begin goto FAILURE end while @progress > 0 BEGIN /* ** Select articles that have either a boolean_filter or atleast one join filter ** into a temp table in an optimized order. */ insert into #art(art_nick, article_level) select nickname, @article_level from sysmergearticles where pubid=@pubi and nickname not in (select art_nick from #art) and nickname not in (select art_nickname from sysmergesubsetfilters where pubid=@pubid and join_nickname not in (select art_nick from #art)) /* ** NOTENOTE: add error checking here. */ set @progress = @@rowcount select @article_level = @article_level + HB/B6SplitNextDZ B-L {/ @ L-ZBw0vL-Z B-Zve wreL-Z Bv-Z wn L-Z B)D-Z{| w P-Z B -Z4-ZBB6-ZV0-Z?w-Z 0{| 1 END /* Drop the old views and reset sync_objid */ select @art_nick = min(nickname) from sysmergearticles where pubid = @pubid and sync_objid <> objid while @art_nick is not null begin /* Drop the old view */ select @viewname = OBJECT_NAME (sync_objid) from sysmergearticles where pubid = @pubid and nickname = @art_nick if @viewname IS NOT NULL begin select @quoted_view = QUOTENAME(@viewname) exec ('drop view ' + @quoted_view) end /* Update the row in sysmergearticles */ update sysmergearticles set view_type = 0, sync_objid = objid where pubid = @pubid and nickname = @art_nick if @@ERROR <> 0 goto FAILURE /* Find the next one */ select @art_nick = min(nickname) from sysmergearticles where pubid = @pubid and sync_objid <> objid end set art = 0 select @art=min(indexcol) from #art where indexcol>@art while (@art is not null) begin select @art_nick=art_nick, @article_level = article_level from #art where indexcol = @art select @article = name, @artid = artid, @source_objid = objid, @sync_objid = sync_objid, @procname = view_sel_proc from sysmergearticles where nickname=@art_nick and pubid = @pubid select @quoted_proc = QUOTENAME(@procname) exe @retcode = dbo.sp_MSguidtostr @artid, @guidstr out if @@ERROR <>0 OR @retcode <>0 return (1) select @source_object = QUOTENAME(user_name(uid)) + '.' + QUOTENAME(name) from sysobjects where id = @source_objid select @bool_filterclause=subset_filterclause from sysmergearticles where name = @article and pubid = @pubid set @rgcol = NULL select @rgcol = QUOTENAME(name) from syscolumns where id = @source_objid and ColumnProperty(id, name, 'isrowguidcol') = 1 if @rgcol is not NULL set @hasguid = 1 else begin set @hasguid = 0 set @allhaveguids = 0 end /* ** Process non looping articles that have either a boolean or a join_filter. */ if ( @article_level > 0 OR (len(@bool_filterclause) > 0) ) begin /* ** If the article has a previously generated vew, then drop the view before ** creating the new one. */ set @viewname = NULL select @viewname = name from sysobjects where id = @sync_objid and ObjectProperty (id, 'IsView') = 1 and ObjectProperty (id, 'IsMSShipped') = 1 if @viewname IS NOT NULL begin select @quoted_view = QUOTENAME(@viewname) exec ('drop view ' + @quoted_view) if @@ERROR<>0 return (1) end /* ** Any join filter(s)? If any, process join filter(s) */ if (@article_level > 0) begin declare pub1 CURSOR LOCAL FAST_FORWARD FOR select join_filterclause, join_nickname, join_articlename, join_unique_key, join_filterid from sysmergesubsetfilters where pubid=@pubid and artid=@artid FOR READ ONLY open pub1 fetch pub1 into @join_filterclause, @join_nick, @join_articlename, @join_unique_key, @join_filterid select @unqual_jointable = QUOTENAME(name) from sysobjects where id = (select objid from sysmergearticles where name=@join_articlename and pubid=@pubid) select @join_viewname = object_name(sync_objid) from sysmergearticles where nickname = @join_nickd, -Z?w-Z0{|  and pubid = @pubid select @join_viewname = QUOTENAME(@join_viewname) if (@join_unique_key = 1 and (@bool_filterclause is null or len(@bool_filterclause) = 0) and not exists (select * from sysmergesubsetfilters where pubid=@pubid and artid=@artid and join_filterid <> @join_filterid)) begin set @simple_join_view = 1 set @view_rule = 'select '+ @source_object + '.* from ' + @source_object + ', ' + @join_viewname + ' ' + @unqual_jointable + ' where ' + @join_filterclause end else begin set @simple_join_view = 0 set @view_rule = 'select ' + @source_object + '.rowguidcol from ' + @source_object + ', ' + @join_viewname + ' ' + @unqual_jointable + ' where ' + @join_filterclause end fetch nxt from pub1 into @join_filterclause, @join_nick, @join_articlename, @join_unique_key, @join_filterid WHILE (@@fetch_status <> -1) begin select @unqual_jointable = name from sysobjects where id = ( select objid from sysmergearticles where name=@join_articlename and pubid=@pubid) select @join_viewname = object_name(sync_objid) from sysmergearticles where nickname = @join_nick and pubi = @pubid select @join_viewname = QUOTENAME(@join_viewname) set @view_rule = @view_rule + ' union select ' + @source_object + '.rowguidcol from ' + @source_object + ', ' + @join_viewname + ' ' + @unqual_jointable + ' where ' + @join_filterclause fetch next from pub1 into @join_filterclause, @join_nick, @join_articlename, @join_unique_key, @join_filterid end close pub1 deallocate pub1 if len(@bool_filterclause) > 0 set @view_rule = @view_rule + ' union select ' + @source_object + '.rowguidcol from '+ @source_object + ' where '+ @bool_filterclause -- Now do the actual view rule as a semi-join, if not a simple join on unique key if (@simple_join_view = 0) set @view_rule = 'select * from ' + @source_object + ' where rowguidcol in (' + @view_rule + ')' end else /* boolean filter only */ select @view_rule = ' select * from '+ @source_object + ' where '+ @bool_filterclause select @viewname = @publication + '_' + @article + '_VIEW' exec @retcode = dbo.sp_MSuniqueobjectname @viewname , @viewname output select @quoted_view = QUOTENAME(@viewname) if @retcode <> 0 or @@ERROR <> 0 return (1) /* If we havent generated rowguidcol yet, se dummy rule that doesnt refer to it */ if @hasguid = 0 set @view_rule = ' select * from '+ @source_object exec ('create view '+ @quoted_view + ' as '+ @view_rule) /* Mark view as system object */ execute ('sp_MS_marksystemobject ' + @quoted_view) if @hasguid = 1 begin if @procname is not null begin exec ('drop procedure ' + @uoted_proc) end else begin set @procname = 'sel_' + substring(@guidstr, 1, 16) + substring(@pubidstr, 1, 16) exec @retcode = dbo.sp_MSuniqueobjectname @procname , @procname output if @retcode <> 0 or @@ERROR <> 0 return (1) end select @owner = user_name(uid) from sysobjects T HC/B6SplitNext8-ZC-=V0L-Z C-Z|/D-Z C-Z|/ @ 8-Z C-@x8L-ZCx0wvL-ZCw-Zv@xlL-ZCv-Z w@xiL-ZC)E-Z {| x P-Z C -Z 4-ZCB6-ZV0-Z?x-Z0{|  where name = @viewname exec dbo.sp_MSmakeviewproc @viewname, @owner, @procname, @rgcol end update sysmergearticles set sync_objid = OBJECT_ID (@viewname), view_type = @permnent, view_sel_proc = @procname where artid = @artid and pubid = @pubid end /* end of view creation for this article */ else if @procname is null and @hasguid = 1 begin /* still make the select proc, although it selects directly from table */ set @procname = 'sel_' + substring(@guidstr, 1, 16) + substring(@pubidstr, 1, 16) exec @retcode = dbo.sp_MSuniqueobjectname @procname , @procname output if @retcode <> or @@ERROR <> 0 return (1) select @owner = user_name(uid), @viewname = name from sysobjects where id = @source_objid exec dbo.sp_MSmakeviewproc @viewname, @owner, @procname, @rgcol update sysmergearticles set view_sel_proc = @procname where artid = @artid and pubid = @pubid end select @art=min(indexcol) from #art where indexcol>@art end /* If there are looping articles, we must us a dynamic publication since no views on temp tables */ update sysmergearticles set view_type = @temporary where pubid=@pubid and nickname not in (select art_nick from #art) if @@rowcount > 0 begin if not exists (select * from sysmergepublications where dynamic_filters = 1 and pubid = @pubid) begin declare @repl_nick int /* treat these articles as if the publication were dynamic */ execute @retcode = dbo.sp_MSgetreplnik @nickname = @repl_nick output if (@@error <> 0) or @retcode <> 0 or @repl_nick IS NULL begin RAISERROR (14055, 11, -1) RETURN(1) end select @art_nick = min(nickname) from sysmergearticles where pubid = @pubid and view_type = @temporary while @art_nick is not null begin /* Loop over articles with circular filters. Create dummy view and add rows to contets */ select @article = name, @artid = artid, @source_objid = objid, @sync_objid = sync_objid, @procname = view_sel_proc from sysmergearticles where nickname=@art_nick and pubid = @pubid select @source_object = QUOTENAME(user_name(uid)) + '.' + QUOTENAME(name) from sysobjects where id = @source_objid set @viewname = NULL select @viewname = name from sysobjects where id = @sync_objid and ObjectProperty (id, 'IsView') = 1 and ObjectProperty (id, 'IsMSShipped') = 1 if @viewname IS NOT NULL begin select @quoted_view = QUOTENAME(@viewname) exec ('drop view ' + @quoted_view) if @@ERROR<>0 return (1) end select @viewname = 'SYNC_' + @publication + '_' + @article exec @retcode = dbo.sp_MSuniquobjectname @viewname , @viewname output if @retcode <> 0 or @@ERROR <> 0 return (1) select @quoted_view = QUOTENAME(@viewname) exec ('create view ' + @quoted_view + ' as select * from ' + @source_object + ' where 1 = 0 ') if @@ERROR<>0 return (1) update sysmergearticles set sync_objid = OBJECT_ID (@viewname), view_sel_proc = NULL where artid = @artid and pubid = @pubid if @@ERROR<>0 return (1) select @owner = user_name(uid) from sysobjects where id = @source_objid set @table = OBJECT_NAME(@source_objid) exec @retcode = d -Z?x-Z0{| bo.sp_addtabletocontents @table, @owner IF @@ERROR <> 0 or @retcode <> 0 return (1) select @art_nick = min(nickname) from sysmergearticles where pubid = @pubid and view_tpe = @temporary and nickname > @art_nick end end end drop table #art if @allhaveguids = 1 begin declare @dbname sysname set @dbname = db_name() /* create the filter expand procs now */ set @filter_id = 0 select @filter_id = min(join_filterid) from sysmergesubsetfilters where pubid = @pubid and join_filterid > @filter_id while @filter_id is not null begin set @filter_id_str = convert(nvarchar(10), @filter_id) select @procname = expand_proc from sysmergesubsetfilters where pubid = @pubid and join_filterid = @filter_id /* drop old proc, or generate a new procname */ select @quoted_proc = QUOTENAME(@procname) if @procname is not null exec ('drop procedure ' + @quoted_proc) else begin set @procname = 'expand_' + @filter_d_str exec @retcode = dbo.sp_MSuniqueobjectname @procname, @procname output if @retcode <>0 return (1) update sysmergesubsetfilters set expand_proc = @procname where pubid = @pubid and join_filterid = @filter_id end select @quoted_proc = QUOTENAME(@procname) select @quoted_pub = QUOTENAME(@publication) set @command = 'exec dbo.sp_MSmakeexpandproc ' + @quoted_pub + ' , ' + @filter_id_str + ', ' + @quoed_proc exec @retcode = master..xp_execresultset @command, @dbname if @retcode <> 0 return (1) exec dbo.sp_MS_marksystemobject @quoted_proc exec ('grant execute on ' + @quoted_proc + ' to public ') select @filter_id = min(join_filterid) from sysmergesubsetfilters where pubid = @pubid and join_filterid > @filter_id end end return (0) FAILURE: return (1) P-Z ? -ZP-Z ?-ZP-Z ?-Z P-Z ?-Z 4-L?B6-L gftf$fe\LLLLLKhKKJJTJJI9))p)$)((@(''@rom sysmergesubscriptions where (pubid=@pubid) and (subti y e nce0aqu de  i c@ -deb el {=, h-DR@-LhTDv6 user_transaction -D{| t-DR@- **{|  ZI\O #4-Dv6-(@Q0D\UES ('pre_creation_command') INSERT INTO #tab1 VALUES ('creation_script') INSERT INTO #tab1 VALUES 0-@E6 grrev L-EO -@{|  P- E -Z! 4-E6-dV0a0X select * FROM #tab1 RETURN (0) END /* ** Parameter Check: @property. ** Check to make sure that @property is a valid property in ** sysmz-`,k 6E 'description', 'pre_creation_command', 'creation_script', 'column_tracking', 'article_resolver', 're--6-dq  'schema_option') BEGIN RAISERROR (20019, 16, -1) RETURN (1) END e H/6SplitNextD-, -m/ s@p_L-,iZXqr-D c-L(Ap d dF 6.sp_addmergesubscription-F-LG0&p G@publicationi`-FA-L(6p (@publication-F-E0&p E@subscriberogi`-FB-&6p &@subscriber) -F-K0&p K@subscriber_db@d-FC-,6p ,@subscriber_db-F-S0&p S@subscription_typesl-FD-46p 4@subscription_type- F- O0&p O@subscriber_type h- FD- 06p 0@subscriber_type- F- [0&p ;;[@subscription_prioritymt- FE- <6p <@subscription_priority|-F- C0&p C@sync_typel\-FG-$6p $@sync_type-F -M0&p 88 M@frequency_typee ph-FA-.6p .frequency_type @-F!-U0&p 88  U@frequency_interval p-FA-66p  6@frequency_intervalin-F"-g0&p 88  g@frequency_relative_intervalN-FB-H6p  H@frequency_relative_interval-F#-g0&p 88  g@frequency_recurrence_factor -FB-H6p  H@frequency_recurrence_factor-F$-Q0&p 88  Q@frequency_subdayl-FD-26p  2@frequency_subday-F%-c0&p 88  c@frequency_subday_interval |-FE-D6p  D@frequency_subday_interval-F&-a0&p 88 a@active_start_time_of_day |-FA-B6p B@active_start_time_of_day -F'-]0&p 88 ]@active_end_time_of_dayexix-FA->6p >@active_end_time_of_dayBE- F(-S0&p 88 S@active_start_dateil-!FB- 46p 4@active_start_date-"F)-!O0&p 88 O@active_end_date h-#FA-"06p 0@active_end_date-$F*-#[0&p @[@optional_command_line t-%FK-$<6p <@optional_command_line-&F+-%G0&p G@description HG/ 6SplitNextD-( G-Z{/* @ L-)Gw L-*G-& w P-+ G-L-,G(bsswef--Gw-*a((&""&  "&($*, ""((( ,&&****" "6(((,&&****"6.** 6$ 6022,,,0000022,,,06\D (@server_name6z @defb6z (@deflanguage6z &@encryptopter6z "@loginame 6z @passwd S6z @sid6 "@funcnamepu6A &@bOutParams 6A  @columns6A @objid6A  @outvars6A  @postfix6&n"@loginameet6&n@new6&n@old6P"&@agent_type 06P"(@publication6P"$@publisher6P"*@publisher_db 6z,,@filter_clause6z,@objid6z, @op_type6z,"@procname 6z,"@trignameer6@-(@column_name6@-(@column_name6@-(@column_name6@- @grantee6@- @grantee6@- @grantee6@- @grantor6@- @grantor6@- @grantor6@-,@table_catalog6@-&@table_namet 6@-&@table_nameop6@-*@table_schema @6@-*@table_schemaic6@-*@table_schemaco6@-*@table_server 6Jb"@loginameOW6F@typeso6P@objid6P @op_type61oV"@loginame 6jv6@heartbeat_intervalso6@(@column_name6@(@column_name6@(@column_name6@,@table_catalog6@&@table_name6@&@table_name6@*@table_schema6@*@table_schemaL6@*@table_schema6@*@table_server6jJ"@loginame6j6@heartbeat_interval--6%.@bOutput_params N6%*@identity_col i6% *@include_type @6%@indent@s6% @is_new 36%@objid6%  @op_type6% @postfix6%@prefix 6% 6@primary_key_bitmapve6% $@set_nulls6%@spacerte6%@ts_cold 64^@job_idig6^@indentWA6^@is_new 6^@objid6^ @op_type6^ @postfix6^6@primary_key_bitmap@s6^@ts_col 60@fk_catalog_name62@fk_table_cataloged62@fk_table_catalog 6,@fk_tale_name6,@fk_table_name6,@fk_table_name60@fk_table_schema60@fk_table_schema60@fk_table_schema60@fk_table_schema60@pk_catalog_name62@pk_table_catalog/*62@pk_table_catalog, 6,@pk_table_name6,@p_table_name6,@pk_table_name60@pk_table_schema<-. Ga-+wavx8d-/G,,6\D w,@server_nameP-0 G-,4-(G 6-(V0a`-'FE-/(6p (@description-3F,-'W0&p  W@enabled_for_syncmgr p-4FF-386p 8@enabled_for_syncmgrP-5F -Lp ent_P-6F -6p ̅jotoP-7F -7p (e pP-8F -8p (MITP-9F -9p ( P-:F -:p W`P-;F -;p i<P-<F -<p P-=F -=p rWP->F ->p d@reP-?F -?p !Jo P-@F -@p ҕ;e = -AFp 4-BFRF-`0*p P  6 `sp_addmergesubscriptiont-CF%-<6p <sp_addmergesubscriptionD-DFZ{-L p -EF-L#0p CREATE PROCEDURE sp_addmergesubscription ( @publication sysname, /* Publication name */ @subscriber sysname = NULL, /* Subscriber server */ @subscriber_db sysname = NULL, /* Subscription database */ @subscription_type nvarchar(15) = 'push', /* Subscriptin type - push, pull */ @subscriber_type nvarchar(15) = 'local', /* Subscriber type */ @subscription_priority real = NULL, /* Subscription priority */ @sync_type nvarchar(15) = 'automatic', /* subscription sync type */ @frequency_type int = NULL, @frequency_interval int = NULL, @frequency_relative_interval int = NULL, @frequency_recurrence_factor int = NULL, @frequency_subday int = NULL, @frequency_subday_interval int = NULL, @active_start_time_of_day int = NULL, @active_end_time_of_day int = NULL, @active_start_date int = NULL, @active_end_date int = NULL, @optional_command_line nvarchar(4000) = NULL, @description nvarchar(255) = NULL, @enabled_for_syncmgr nvarchar(5) = 'false' /* Enabled fr SYNCMGR: true or false */ ) AS SET NOCOUNT ON /* ** Declarations. */ declare @retcode int declare @subnickname int declare @subscriber_srvid int declare @publisher_srvid int declare @priority real declare @subid uniqueidentifier declare @pubid uniqueidentifier /* Publication id */ declare @subscriber_typeid smallint declare @merge_jobid binary(16) /* Scheduler jobid for the merge agent */ declare @subscription_type_id int declare @distproc nvarchar(255) declare @command nvarchar(255) declare @inactive tinyint declare @subscriber_bit smallint declare @global tinyint /* subscriber type is global */ declare @push tinyint /* subscription type is push */ declare @partnerid unqueidentifier /* Partner replica identifier */ declare @sync_typeid tinyint declare @nosync tinyint declare @automatic tinyint declare @distributor sysname declare @distribdb sysname declare @active tinyint declare @publisher sysname declare @publisher_db sysname declare @found int declare @datasource_type int declre @datasource_path sysname DECLARE @platform_nt binary declare @is_jet int declare @Jet_datasource_path sysname /* ** Initializations. */ set @datasource_type = 0 /* Default SQL Server */ set @datasource_path = NULL set @platform_nt = 0x1 SET @nosync = 2 /* Const: synchronization type 'nosync' */ SET @automatic = 1 /* Const: synchronization type 'automatic' */ set @inactive = 0 SET @subscriber_bit = 4 set @global = 1 set @push = 0 set @pubid = NULL set @active = 1 /* Const: subscription status 'active', 0 for pull subscriptions at publisher side */ set @publisher = @@SERVERNAME set @publisher_db = DB_NAME() select @found = 1 /* Any non-NULL value is fine */ /* ** Parameter Check: @subscription_type. ** Set subscriber_typei based on the @subscHH/ 6SplitNextD-G H-)}/set@@arL-HHyL-IH-F @ye_L-JH(m yec-KHy-I0p CREATE PROCEDURE sp_addmergesubscription ( @publication sysname, /* Publication name */ @subscriber sysname = NULL, /* Subscriber server */ @subscriber_db sysname = NULL, /* Subscription database */ @subscription_type nvarchar(15) = 'push', /* Subscription type - push, pull */ @subscriber_type nvarchar(15) = 'local', /* Subscriber type */ @subscription_priority real = NULL, /* Subscription priority */ @sync_type nvarchar(15) = 'automatic', /* subscription sync type */ @frequency_type int = NULL, @frequency_interval int = NULL, @frequency_relative_interval int = NULL, @frequency_recurrence_factor int = NULL, @frequency_subday int = NULL, @frequency_subday_interval int = NULL, @active_start_time_of_day int = NULL, @active_end_time_of_day int = NULL, @active_start_date int = NULL, @active_end_date int = NULL, @optional_command_line nvarchar(4000) = NULL, @description nvarchar(255) = NULL, @enabled_for_syncmgr nvarchar(5) = 'false' /* Enabled for SYNCMGR: true or false */ ) AS SET NOCOUNT ON /* ** Declarations. */ declare @retcode int declare @subnckname int declare @subscriber_srvid int declare @publisher_srvid int declare @priority real declare @subid uniqueidentifier declare @pubid uniqueidentifier /* Publication id */ declare @subscriber_typeid smallint declare @merge_jobid binary(16) /* Scheduler jobid for the merge agent */ declare @subscription_type_id int declare @distproc nvarcar(255) declare @command nvarchar(255) declare @inactive tinyint declare @subscriber_bit smallint declare @global tinyint /* subscriber type is global */ declare @push tinyint /* subscription type is push */ declare @partnerid uniqueidentifier /* Partner replica identifier */ declare @sync_typeid tinyint declare @nosync tinyint declare @utomatic tinyint declare @distributor sysname declare @distribdb sysname declare @active tinyint declare @publisher sysname declare @publisher_db sysname declare @found int declare @datasource_type int declare @datasource_path sysname DECLARE @platform_nt binary declare @is_jet int declare @Jet_datasource_path sysname /* ** Initializations. */ set @datasource_type = 0 /* Default SQL Server */ set @datasource_path = NULL set @platform_nt = 0x1 SET @nosync = 2 /* Const: synchronization type 'nosync' */ SET @automatic = 1 /* Const: synchronization type 'automatic' */ set @inactive = 0 SET @subscriber_bit = 4 set @global = 1 set @push = 0 set @pubid = NULL st @active = 1 /* Const: subscription status 'active', 0 for pull subscriptions at publisher side */ set @publisher = @@SERVERNAME set @publisher_db = DB_NAME() select @found = 1 /* Any non-NULL value is fine */ /* ** Parameter Check: @subscription_type. ** Set subscriber_typeid based on the @subsc if<-L H-Jyx8L-MH)H-Zp y P-N H -14-GH 6-GV0-FFy-L0p ription_type specified. ** ** subscription_type subscription_type ** ================= =============== ** 0 push ** 1 pull */ if LOWER(@subscription_type) NOT IN ('push', 'pull') BEGIN RAISEROR (14128, 16, -1) RETURN (1) END IF LOWER(@subscription_type) = 'push' set @subscription_type_id = 0 else set @subscription_type_id = 1 /* ** Security Check. */ IF @subscription_type_id = 0 BEGIN exec @retcode = dbo.sp_MSreplcheck_publish if @@ERROR <> 0 or @retcode <> 0 return(1) END ELSE BEGIN exec @retcode = dbo.sp_MSreplcheck_pull @publication if @@ERROR <> or @retcode <> 0 return(1) END /* This SP is called through UI with a subscription_type = pull; in this scenario ** the status of the subscription is inactive before merge agent is run */ if @subscription_type_id = 1 select @active = 0 /* ** Validate that the publisher is a valid server */ select @publisher_srvid = srvid from master..sysservers where UPPER(srvname) = UPPER(@publisher) IF @publisher_srvid IS NULL EGIN RAISERROR (14010, 16, -1) RETURN (1) END /* ** Parameter Check: @subscriber ** Check to make sure that the subscriber is defined */ IF @subscriber IS NULL BEGIN RAISERROR (14043, 16, -1, '@subscriber') RETURN (1) END IF NOT EXISTS (SELECT * FROM master..sysservers WHERE UPPER(srvname) = UPPER(@subscriber) AND (srvstatus & @subscriber_bit) <> 0) BEGIN RAISERROR (14010, 16, -1) RETURN (1) END IF @subscriber = 'all' BEGIN RAISERROR (14136, 16, -1) RETURN (1) END /* ** 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_MShelp_subscriber_info ' exec @distproc @publisher, @subscriber, @found output if (@found <> 1) BEGIN RAISERROR (14085, 16, -1) RETURN (1) END select @distproc = RTRIM(@distributor) + '.' + RTRIM(@distribdb) + '.dbo.sp_MScheck_Jet_Subscriber ' exec @retcode = @distproc @subscriber, @is_jet OUTPUT, @Jet_datasource_path OUTPUT if @retcode<>0 reurn (1) IF @is_jet = 1 BEGIN select @datasource_type = 2 select @datasource_path = @Jet_datasource_path END EXECUTE @retcode = dbo.sp_validname @subscriber IF @@ERROR <> 0 OR @retcode <> 0 RETURN (1) /* ** Parameter Check: @subscriber_db */ IF @subscriber_db IS NULL BEGIN RAISERROR (14043, 16, -1, '@subscriber_db') RETURN (1) END IF @subscriber_db = 'all' BEGIN RAISERROR (14136, 16, -1) RETURN (1) END /* ** Check to see if system tables exist. If not create them. Since under current ** design every database is qualified for subscribing. */ IF not exists (select name from sysobjects where name='sysmergesubscriptions') BEGIN execute @retcode = dbo.sp_MScreate_mergesystables if @@ERROR <> 0 or @retcode <> 0 begin return (1) end END /* ** Parameter Check: @publication. ** Check to make sure that the publication existsHI/ 6SplitNextD-R I-H~/@L-SIz0yL-TIy-Qz6L-UI-KyizL-VI)I-Np zeP-W I -O4-RI 6-RV0-QFz-T0p  and that it conforms ** to the rules for identifiers. */ if NOT EXISTS (select * FROM sysmergepublications WHERE name = @publication and UPPER(publisher)=UPPER(@@servername) and publisher_db=db_name()) BEGIN RAISERROR (20026, 16, -1, @publication) RETURN (1) END if @pubid IS NULL select @pubid = pubid FROM sysmergepublications WHERE name = @publication and UPPER(publisher)=UPPER(@@servername) and publisher_db=db_name() if @partnerid IS NULL begin select @partnerid = subid FROM sysmergesubscriptions WHERE srvid = @publisher_srvid and db_name = @publisher_db and pubid = @pubid end /* ** Parameter Check: @subscriber_type. ** Set subscriber_typeid based on the @subscriber_type specified. ** ** subscriber_type subscriber_type ** ================= =============== ** 1 global ** 2 local ** 3 anonymous ** Type 'republisher' is taken out for B3. We may want to add this back later. */ if LOWER(@subscriber_type) NOT IN ('local', 'globl', 'anonymous') BEGIN RAISERROR (20023, 16, -1) RETURN (1) END if LOWER(@subscriber_type) IN ('global') set @subscriber_typeid = 1 else if LOWER(@subscriber_type) IN ('local') set @subscriber_typeid = 2 else if LOWER(@subscriber_type) IN ('anonymous') set @subscriber_typeid = 3 /* Do not allow anonymous for a PUSH subscription */ if @subscriber_typeid = 3 and @subscription_type_id = 0 BEGIN RAISERROR (20087, 16, -1) RETURN (1) END /* ** Assign priority appropriately - choose 0.99 times the minimum priority ** of the global replicas. */ if (@subscription_priority >= 100.0 or @subscription_priority < 0.0) BEGIN RAISERROR (20088, 16, -1) RETURN (1) END if (@subscription_priority IS NULL) begin select @priority = 0.99 * min(priority) from sysmergesubscriptions where subsriber_type = 1 if (@priority IS NOT NULL) select @subscription_priority = @priority if (@subscription_priority IS NULL) select @subscription_priority = 0.0 end /* ** For local and anonymous subscriptions the priority is 0.0 */ if LOWER(@subscriber_type) IN ('local', 'anonymous') select @subscription_priority = 0.0 /* ** Validate that the subscriber is a valid server */ select @subscrber_srvid = srvid from master..sysservers where UPPER(srvname) = UPPER(@subscriber) IF @subscriber_srvid IS NULL BEGIN RAISERROR (14010, 16, -1) RETURN (1) END IF exists (select * from sysobjects where name= 'syssubscriptions') begin if exists (select name from sysmergearticles where pubid=@pubid and objid in (select objid from sysarticles where artid in (select artid from syssubscriptions where dest_db=@subcriber_db and srvid=@subscriber_srvid))) begin RAISERROR(20084, 16, -1, @publication, @subscriber_db) RETURN (1) end end /* ** Making it possible for a deleted subscription to come back. ** UNDONE : This disallows second pull subscription from being added unless the previous ** subscription was initial synced. */ if EXISTS (select db_name, srvid FROM sysmergesubscriptions WHERE db_name = @subscriber_b AND srvid = @subscriber_srvid AND pubid = @pubid AND status <>2) --We can definitely add back subscription ``0`__L__^t^NPNNMxM=<=<<`<<(,+p+**h**)x)()((8(''H'&&%%d%%$t$|,P$  p X ` @  0XP`h @\ from objid */ sync_object_owner sysname NOT NULL, sync_object dsic a  t B0Re ahi d ai o okbd@ -.r--ZFz-Z0p s 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 = @suscriber_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 nosync */ IF LOWER(@sync_type) NOT N ('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) = 'automatic' BEGIN SET @sync_typeid = @automatic END ELSE BEGIN if exists (select * from sysmergearticles a where pubid=@pubid and not exists (select * from syscolumns c where c.id = a.objid and Columnroperty(c.id, c.name, 'IsRowGuidCol') = 1)) BEGIN Raiserror(20086, 16, -1, @publication) RETURN (1) END else SET @sync_typeid = @nosync END /* ** UNDONE: Validate that the publisher is of type "republisher" */ begin tran save TRAN addmergesubscription /* Generate a guid for the Subscriber ID */ /* Look for existing nickname from any other subscription */ exec @retcode = dbo.sp_MSgetreplnick @subscriber, @subscriber_db , NULL, @subnickname out if (@@error <> 0) or @retcode <> 0 GOTO FAILURE /* Generate a new replica nickname from the @subid */ if (@subnickname is null) begin EXECUTE dbo.sp_MSgenreplnickname @subid, @subnickname output if @@ERROR<>0 GOTO FAILURE end /* ** The subscription doesn't exist, so let'sadd it to sysmergesubscriptions */ INSERT sysmergesubscriptions (subid, partnerid, datasource_type, datasource_path, srvid, db_name, pubid, status, subscriber_type, subscription_type, priority, sync_type, description, login_name) VALUES (@subid, @partnerid, @datasource_type, @datasource_path, @subscriber_srvid, @subsciber_db, @pubid, @active, @subscriber_typeid, @subscription_type_id, @subscription_priority, @sync_typeid, @description, suser_sname(suser_sid())) if @@ERROR <> 0 BEGIN GOTO FAILURE END /*  HJ/ 6SplitNextD- J-S/$@PL-J{0zL-Jz-{L-J-Vz,{ L-J)J-Wp {yP- J -X4-J%6-V0-F{-0p  ** 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_MSadd_merge_subscription' EXEC @retcode = @distproc @publisher = @@SERVERNAME, @publisher_db = @publisher_db, @publication = @publication, @subscriber = @subscriber, @subscriber_db = @subscriber_db, @subscription_type = @subscription_type_id, @sync_type = @sync_typeid, @status = @active, @frequency_type = @frequency_type, @frequency_interval = @frequency_interval, @frequency_relative_interval = @frequency_relative_interval, @frequency_recurrence_factor = @frequency_recurrence_factor, @frequency_subday = @frequency_subday, @frequency_subday_interval = @frequency_subday_interval, @active_start_time_of_day = @active_start_time_of_day, @active_end_time_of_day = @active_end_time_of_day, @active_start_date = @active_start_date, @active_end_date = @active_end_date, @optional_command_line = @optional_command_line, @merge_jobid = @merge_jobid OUTPUT IF @@ERROR <> 0 OR @retcode <> 0 begin goto FAILURE end /* ** Add row for subscription in MSmerge_replinfo. */ insert MSmerge_replinfo(repid, replnickname, merge_jobid) values (@subid, @subnickname, @merge_jobid) if @@ERROR<> 0 BEGIN GOTO FAILURE END /* Conditional support for MobileSync */ if LOWER(@enabled_for_syncmgr) = 'true' BEGIN /* MobileSync Support */ declare @distributor_server sysname declare @distributor_security_mode int declare @distributor_login sysname declare @distributor_password sysname /* ** The registry entry needs to be created 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 @subscription_type_id = 0 BEGIN EXECUTE @retcode = dbo.sp_helpdistributor @distributor = @distributor_server OUTPUT /* Distributor RPC server name */ IF @@ERROR <> 0 or @retcode <> 0 BEGIN GOTO FAILURE END -- Always use integrated security on winNT if (@platform_nt = platform() & @platform_nt ) begin set @distributor_security_mode = 1 end -- For Win9x the dist publisher and distributor are the same machine else bein select @distributor_security_mode = 0, @distributor_login = login, @distributor_password = password from msdb..MSdistpublishers where UPPER(name) = UPPER(@@servername) end /* Call sp_MSregistersubscription so that the subscription can be synchronized via Onestop etc. */ exec @retcode = dbo.sp_MSregistersubscription @replication_type = 2, @publisher = @@SE - F{-  0p  RVERNAME, @publisher_db = @publisher_db, @publication = @publication, @subscriber = @subscriber, @subscriber_db = @subscriber_db, @distributor = @distributor, @distributor_security_mode = @distributor_security_mode, @distributor_login = @distributor_login, @distributor_password = @distributor_password, @subscription_id = @subid, @subscription_type = @subscription_type_id IF @@error <> 0 OR @retcode <> 0 BEGIN GOTO FAILURE END END END COMMIT TRAN return (0) FAILURE: RAISERROR (14057, 16, -1) /* UNDONE : This code is specific to 6.X nested transaction semantics */ if @@TRANCOUNT > 0 begin ROLLBACK TRANSACTION addmergesubscription COMMIT TRANSACTION end RETURN (1) eP- F -P- F- P- F- P- F-4-F%6- -@-,,P,8"Hx,Pd g  r PIb.-DRF-C7TK]6 user_transaction -Kp t-KRF- **p  @cose `_b = 4-K]6-(@Q0D\lues first before changing them */ IF (@reserved = 0) BEGIN SELECT @implicit_transaction = @@options & 2 SELECT @0-@L6 grrevLOL-LQ -p  P- L - 4-L6-dV0[0X ** Security Check */ EXEC @retcode = dbo.sp_MSreplcheck_publish IF @@ERROR <> 0 or @retcode <> 0 return (1) /* ** Check to make sure that this database is enabled for%,.-D c-(Ad &YhMC64sp_changemergesubscription-M<-4G0&d G@publicationn`-Mw-.(6d (@publication-M=-E0&d E@subscribercat`-Mw-&6d &@subscriberer-M>-K0&d K@subscriber_db d-Mw-,6d ,@subscriber_db|-M?-A0&d A@property @\- M-"6d "@propertylit- M@- ;0&d ;@valueLT- Mw- 6d @valueP- M -Ad 8bmcleP- M - d  P-M -d ( PM -d (resP-M -d x} -Md 4-M( f0*d P H6 fsp_changemergesubscriptioner|-MW-DB6d Bsp_changemergesubscription6D-MZ-E d HN/H6SplitNextD- N-/@L-N|L-N(!|L-N"|-N|- @0z  create procedure sp_addlogin @oginame sysname ,@passwd sysname = Null ,@defdb sysname = 'master' -- UNDONE: DEFAULT CONFIGURABLE??? ,@deflanguage sysname = Null ,@sid varbinary(16) = Null ,@encryptopt varchar(20) = Null AS -- SETUP RUNTIME OPTIONS / DECLARE VARIABLES -- set nocount on Declare @ret int -- return value of sp call -- CHECK PERMISSIONS -- IF (not is_srvrolemember('securityadmin') = 1) begin raiserror(15003,-1,-1, 'securityadmin') return () end -- DISALLOW USER TRANSACTION -- set implicit_transactions off IF (@@trancount > 0) begin raiserror(15002,-1,-1,'sp_addlogin') return (1) end -- VALIDATE LOGIN NAME AS: -- (1) Valid SQL Name (SQL LOGIN) -- (2) No backslash (NT users only) -- (3) Not a reserved login name execute @ret = sp_validname @loginame if (@ret <> 0) return (1) if (charindex('\', @loginame) > 0) begin raiserror(15006,-1,-1,@loginame) return 1) end --Note: different case sa is allowed. if (@loginame = 'sa' or lower(@loginame) in ('public')) begin raiserror(15405, -1 ,-1, @loginame) return (1) end -- LOGIN NAME MUST NOT ALREADY EXIST -- if exists(select * from master.dbo.syslogins where loginname = @loginame) begin raiserror(15025,-1,-1,@loginame) return (1) end -- VALIDATE DEFAULT DATABASE -- IF db_id(@defdb) IS NULL begin raiserror(15010,-1,-1,@defdb) return (1) end -- VALIDATE DEAULT LANGUAGE -- IF (@deflanguage IS NOT Null) begin Execute @ret = sp_validlang @deflanguage IF (@ret <> 0) return (1) end ELSE begin select @deflanguage = name from master.dbo.syslanguages where langid = @@default_langid --server default language if @deflanguage is null select @deflanguage = N'us_english' end -- VALIDATE SID IF GIVEN -- if ((@sid IS NOT Null) and (datalength(@sid) <> 16)) begin raiserror(15419,-1,-1) return (1) end else if @sid isnull select @sid = newid() if (suser_sname(@sid) IS NOT Null) begin raiserror(15433,-1,-1) return (1) end -- VALIDATE AND USE ENCRYPTION OPTION -- declare @xstatus smallint select @xstatus = 2 -- access if @encryptopt is null select @passwd = pwdencrypt(@passwd) else if @encryptopt = 'skip_encryption_old' begin select @xstatus = @xstatus | 0x800, -- old-style encryption @passwd = convert(sysname, convert(varbinary(30), convert(varchar(30), @passwd))) end else if encryptopt <> 'skip_encryption' begin raiserror(15600,-1,-1,'sp_addlogin') return 1 end -- ATTEMPT THE INSERT OF THE NEW LOGIN -- INSERT INTO master.dbo.sysxlogins VALUES (NULL, @sid, @xstatus, getdate(), getdate(), @loginame, convert(varbinary(256), @passwd), db_id(@defdb), @deflanguage) -- FINALIZATION: RETURN SUCCESS/FAILURE -- if @@error <> 0 return (1) raiserror(15298,-1,-1) return (0) -- sp_addlogin 0 @crete proc sp_MScreate_replication_status_table as declare @retcode int if (select object_id('tempdb.dbo.MSreplication_agent_status')) is NULL begin -- begin tran create table tempdb.dbo.MSreplication_agent_status ( publisher sysname NOT NULL, publisher_db sysname NOT NULL, publication sysname NOT NULL, publication_type int NOT NULL, -- 0 transactional/snapshot 1 Merge agent_type int NOT NULL, status int NOT NULL, agent_name nvarchar(100) NOT NULL, timestamp NOT NULL, CONSTRAINT pk_MSrepl PRIMARY KEY (timestamp, agent_type) ) if @@error <> 0 return 1 create nonclustered index uncMSreplication_agent_status ON tempdb.dbo.MSreplication_agent_status (status, publisher, publisher_db, publication, agent_type) if @@error <> 0 return 1 end return 0 - If here, all is well and we're done. <- N-|dx8L-N)N-z |d P- N -4-NH6-V0-M-0d  CREATE PROCEDURE sp_changemergesubscription ( @publication sysname = NULL, /* Publication name */ @subscribe sysname = NULL, /* Subscriber server */ @subscriber_db sysname = NULL, /* Subscription database */ @property sysname = NULL, /* The property to change */ @value nvarchar(255) = NULL /* The new property value */ ) AS SET NOCOUNT ON /* ** Declarations. */ declare @subscriber_bit smallint declare @subscriber_srvid int declare @publisher_srvid int declare @retcode int declare @pubid uniqueidentifier declare @subid uniqueidentifier declare @partnerid uniqueidentifier declare @sync_typeid tinyint declare @nosync tinyint declare @automatic tinyint declare @artid uniqueidentifier declare @schematype int declare @schemaversion int declare @schemaguid uniqueidentifier declare @db_nam sysname declare @subscriber_type int declare @schematext nvarchar(2000) declare @publisher sysname declare @publisher_db sysname /* ** Initializations. */ SET @nosync = 2 /* Const: synchronization type 'none' */ SET @automatic = 1 /* Const: synchronization type 'automatic' */ set @publisher = @@SERVERNAME set @publisher_db = DB_NAME() /* ** Securiy Check. */ BEGIN exec @retcode = dbo.sp_MSreplcheck_subscribe if @@ERROR <> 0 or @retcode <> 0 return(1) END /* ** Check to see if current database is doing publishing/subscribing */ IF not exists (select name from sysobjects where name='sysmergesubscriptions') BEGIN RAISERROR (14055, 16, -1) RETURN (1) END /* ** Parameter Check: @property. ** If the @property parameter is NLL, print the options. */ IF @property IS NULL BEGIN CREATE TABLE #tab1 (properties sysname) INSERT INTO #tab1 VALUES ('sync_type') INSERT INTO #tab1 VALUES ('priority') INSERT INTO #tab1 VALUES ('description') select * FROM #tab1 RETURN (0) END /* ** Parameter Check: @publication. ** Make sure that the publication exists. */ IF @publication IS NULL BEGIN RAISERROR (14043, 16, -1, '@publication') 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 BEGIN RAISERROR (20026, 11, -1, @publication) RETURN (1) END /* ** Validate that the publisher is a valid server */ select @publisher_srvid = srvid from master..sysservers wher UPPER(srvname) = UPPER(@publisher) IF @publisher_srvid IS NULL BEGIN RAISERROR (14010, 16, -1) RETURN (1) END /* ** Parameter Check: @subscriber. ** Check to make sure we have a valid subscriber. */ IF @subscriber IS NULL BEGIN RAISERROR (14043, 16, -1, '@subscriber') RETURN (1) END /* ** Validate that the subscriber is a valid server */ select @subscriber_srvid = srid from master..sysservers where UPPER(srvname) = UPPER(@subscriber) IF @subscriber_srvid IS NULL BEGIN RAISERROR (14010, 16, -1) RETURN (1) END /* ** Check to see if you have a local / global subscription on this publication V0HO/H6SplitNextD-! O-/ @ bL-"O}0|L#O- |}L-$O|-}pH,++l+$+4d( @ d\L\ Dl$D\- G0&^G@publication`-)$- (6^(@publication-)Z-G0&^-ve Ute r- a@ F(1l-w .-n`-)$-(6^(@description|-)[-C0&^88 C@retention\-)&-$6^$@retention|-)\-C0&^C@sync_modep\- )'-$6^$@sync_mode- )]- E0&^ E@allow_pushe`- )$- &6^&@allow_push- )^- E0&^ E@allow_pulls`- )$- &6^&@allow_pull-)_- O0&^ O@allow_anonymoush-)$-06^0@allow_anonymous-)`-Y0&^ Y@enabled_for_internett-)(-:6^:@enabled_for_internet-)a-[0&^  [@centralized_conflictsnt-)'-<6^ <@centralized_conflicts-)b-O0&^  O@dynamic_filtersh-))-06^ 0@dynamic_filtersP-) ^eP-) -^P-) -^劖TP-) -^ P-) -^P-) -^T<H,++l+$+4d( @ d\L\ Dl$DĀ07 0 /  / 0H -- Create temp sp, no security check needed create procedure sp_MSmaketempinsertproc (@tablename sysname, @procname sysname) as declare @arglist nvarchar(4000) declare @collist nvarchar(4000) declare @vallist nvarchar(4000) declare @argname sysname declare @setpc nvarchar(4000) declare @wherepc nvarchar(255) declare @qualname nvarchar(266) declare @id int set @qualname = 'tempdb..' + @tblename select @id = id from tempdb..sysobjects where name = @tablename declare @colname sysname declare @typename sysname declare @colid smallint declare @status tinyint declare @len smallint declare @prec smallint declare @scale int declare @retcode smallint set @wherepc = ' where rowguid = @p2 ' select @colid = 1 select @colname = c.name, @status = c.status, @typename = t.name, @len = c.length, @prec = COLUMNPROPERTY(c.id, c.name, 'precision'), @scale = c.scale from tempdb..syscolmns c, systypes t where c.id = @id and c.colid = @colid and c.xusertype = t.xusertype and c.iscomputed<>1 while (@colname is not null) begin if @typename='nvarchar' or @typename='nchar' -- a unit of nchar takes 2 bytes select @len = @len/2 exec @retcode = dbo.sp_MSmaptype @typename out, @len, @prec, @scale if @@error<>0 or @retcode<>0 return (1) set @argname = '@p' + rtrim(convert(nchar, @colid)) if (@colid = 1) begin set @arglist = @argname + ' ' + @typename set @collist @colname set @vallist = @argname set @setpc = @colname + ' = ' + @argname end else begin set @arglist = @arglist + ', ' + @argname + ' ' + @typename set @collist = @collist + ', ' + @colname set @vallist = @vallist + ', ' + @argname set @setpc = @setpc + ', ' + @colname + ' = ' + @argname end set @colid = @colid + 1 set @colname = NULL select @colname = c.name, @status = c.status, @typename = t.name, @len = c.length, @prec = COLUMNPROPERTY(c.id, c.name, 'precision'), scale = c.scale from tempdb..syscolumns c, systypes t where c.id = @id and c.colid = @colid and c.xusertype = t.xusertype and c.iscomputed<>1 end select @procname = QUOTENAME(@procname) select @tablename = QUOTENAME(@tablename) -- now create the procedure execute ('Create procedure dbo.' + @procname + ' ( ' + @arglist + ') as update ' + @tablename + ' set ' + @setpc + @wherepc + ' if (@@rowcount = 0) insert into ' + @tablename + ' (' + @collist + ') values (' + @vallist + ')') if @@ERROR>0 begin return(1) end P0   /P0  0P0  0 P0  04/ 7/́CV0`  p  create table #tempcmd (step int identity NOT NULL, cmdtext nvarchar(4000) NULL) /*<@=ua 0DP/ /T"7 user_transaction 0"Ht0"P0 **H `be40"70(@f0D\8 / ~4˧i whP/8 /00@#57 grrevL0#\: /H P0 # 0 40#570dV0 0X/idU, L/ *) U- / U/ ,HVTjf<N\HVhRJ^Nph0D c/(AyI-nJh$74sp_MSgetconflictinsertproct0$f"/;0&yI$$;@artidT0$t&/6yI@artidx0$f#0=0&yI88 =@output*X0$t'06yI@outputP0$ / yIoP0$ 0yI˧iP0$ 0yIP0 $ 0 yIP0 $ 0 yIrP0 $ 0 yISP0 $ 0 yIxټqfP0 $ 0 yIGb 0$yI0$P0f0*yIP 7 fsp_MSgetconflictinsertprocv|0$Y=/X B6yIBsp_MSgetconflicinsertprocsD0$[/  yI<L\8\R2 Vsp_addlinkedserver0*Ux9P H`6Psp_helparticle0*9P 42 Hsp_dboption0*9P 5bsp_MSget_qualified_name0*9X IV5 Vxp_trt000$A*0yI /* Add the conflict table pointer to sysmergearticles - Used by reconciler */ CREATE PROCEDURE sp_MSgetconflictinsertproc ( @artid uniqueidentifier, @output int = 1 ) AS declare @conflict_table sysname declare @conflict_proc sysname declare @owner sysname declare @object sysname declare @retcode int declare @basetableid int -- PARSENAME VARS declare @UnqualName nvarchar(258) --rightmost name node declare @QualName1 nvarchar(258) declare @QualName2 nvarchar(258) -- END PARSENAME VARS declare @guidstr varchar(40) exec @retcode=sp_MSguidtostr @artid, @guidstr out if @retcode<>0 or @@ERROR<>0 return (1) /* ** Check to see if current publication has permission */ exec @retcode=sp_MSreplcheck_connection @artid = @artid if @retcode<>0 or @@ERROR<>0 return (1) select @conflict_table = conflict_table, @conflict_proc = ins_conflict_proc, @basetableid = objid from sysmergearticles where artid = @artid if @@ERROR <> 0 return (1) -- Create an index on the conflict table if it doesn't have one if (OBJECT_ID(@conflict_table) is not null) and not exists (select * from sysindexes where id = OBJECT_ID(@conflict_table) and keys is not null) begin declare @rgcol sysname declare @indname sysname declare @quotedname sysname select @rgcol = QUOTENAME(name) from syscolumns where id = @basetableid and ColumnProperty(id, name, 'isrowguidcol') = 1 select @indname = 'uc_' + @conflict_table set @indname = QUOTENAME(@indname) set @quotedname = QUOTENAME(@conflict_table) exec ('Create unique clustered index ' + @indname + ' on ' + @quotedname + ' (' + @rgcol + ', origin_datasource)' ) if @@error <> 0 return (1) end if ((OBJECT_ID(@conflict_proc) is null) and (OBJECT_ID(@conflict_table) is not null)) begin select @UnqualName = PARSENAME(@conflict_table, 1) select @QualName1 = PARSENAME(@conflict_table, 2) if @UnqualName IS NULL return 1 -- fixup for variable length differences. remove when vars expanded -- to new SQL SERVER 7.0 lengths select @owner = @QualName1 select @object = @UnqualName -- first set up the procedure name variable select @conflict_proc = 'sp_cft_' + @guidstr exec @retcode=sp_MSuniqueobjectname @conflict_proc , @conflict_proc output if @@ERROR <> 0 OR @retcode <> 0 return(1) exec @retcode=sp_MSmakeconflictinsertproc @UnqualName, @owner, @conflict_proc, @basetableid if @@ERROR <> 0 OR @retcode <> 0 begin RAISERROR('Failure when creating conflict insertion procedure', 16, -1) return(1) end update sysmergearticles set ins_conflict_proc = @conflict_proc where artid = @artid end if @output = 1 select @conflict_table, @conflict_proc if @@ERROR <> 0 return (1) return (0) P0 $ 0P0 $0P0 $0 P0 $040$70́CV08HMSremovedbreplication 6 &<sp_MSrepl_addrolemember6GNA:sp_MSrepl_check_server 6mR.sp_MSrepl_dbroleD 6Dڎ'>sp_MSrepl_droprolemember= 6?r>4sp_MS0)DP0T%7 user_transaction 0)%yIt0)%P0) **yI_u fhj40)%70)(@f0D\_MSreplcheck_qv68bm>sp_MSreplcheck_subscribeul6\VnDsp_MSrepl00*@&a7 grrevUSL0*&\? 0yI P0* & 0 40*&a70*dV0 0Xoc6z,:sp_MSscript_begintrig1r 6P:sp_MSscript_begintrig2 6<WFsp_MSscript_delete_statement@@690+D c0(A-nJf&bKh'72sp_MSinsertdeleteconflictt|0+'f,0C0&-nJ88 C@tablenick\0+'t00$6-nJ$@tablenickx0+'f-0+?0&-nJ$$?@rowguidX0+'t00+ 6-nJ @rowguid0+'f.0+K0&-nJ88 K@conflict_typed0+'t00+,6-nJ,@conflict_type0+'f/0+G0&-nJ88 G@reason_code`0+ 't10+(6-nJ(@reason_code0+ 'f00+ G0&-nJG@reason_text`0+ 't20+ (6-nJ(@reason_text0+ 'f10+ S0&-nJS@origin_datasourceMl0+ 't10+ 46-nJ4@origin_dataourcet0+'f20+ ;0&-nJ$$;@pubid T0+'t20+6-nJ@pubidP0+'  0-nJ˧i P0+'  0+-nJ.sp 0+'-nJ0+'P0)d0*-nJP 7 ds_MSinsertdeleteconflictx0+'" / @6-nJ@sp_MSinsertdeleteconflictD0+'[0 -nJT0+'*0-nJ create PROCEDURE sp_MSinsertdeleteconflict( @tablenick int, @rowguid uniqueidentifier, @conflict_type int, @reason_code int, @reason_text nvarchar(720), @origin_datasource nvrchar(255), @pubid uniqueidentifier) as declare @retcode int /* ** Check to see if current publication has permission */ exec @retcode=sp_MSreplcheck_connection @tablenick = @tablenick if @retcode<>0 or @@ERROR<>0 return (1) /* Parameter validation */ if (@tablenick is null) begin RAISERROR(14043, 16, -1, '@tablenick') return (1) end if (@rowguid is null) begin RAISERROR(14043, 16, -1, '@rowguid') return (1) end if (not exists(select * from sysobjcts where name = 'MSmerge_contents')) begin RAISERROR(20054 , 16, -1) return (1) end /* Don't insert a duplicate row */ if (not exists (select * from MSmerge_delete_conflicts where tablenick = @tablenick and rowguid = @rowguid and origin_datasource = @origin_datasource)) insert into MSmerge_delete_conflicts (tablenick, rowguid, conflict_type, reason_code, reason_text, origin_datasource, pubid) values (@tablenick, @rowguid, @conflict_type, @reason_code, @reason_text, @origin_daasource, @pubid) if @@ERROR <> 0 return (1) return (0) P0+ ' 0*P0+ '0+P0+ '0+ P0+ '0+40+'70+́CV00@0t$ 4Tl@\ts select @rteaps03DP0+T(B7 user_transaction 03(-nJt03(P03 **-nJ?@ge dif403(B703(@f0D\ @genguidp/%/70& g688 7@g004@)7 grrevtL04)\E 0*-nJ P04 ) 0+ 404)704dV0&0X.V0L/  / /D/  / /@98/  ! 05D c0+(Af&bKJVLd*#7.sp_MScheckmetadatamatch|05*f:0+A0&f&bK00A@metatype \05*t>0+"6f&bK"@metatype(x05*f;05?0&f&bK$$?@rowguidX05*t?05 6f&bK @rowguid|05*f<05C0&f&bK88 C@tablenick\05*t@05$6f&bK$@tablenickx05*f=05?0&f&bK?@lineageX05 *t>05 6f&bK lineaget05 *f>05 ;0&f&bK88 ;@matchT05 *t?05 6f&bK@match 05 *f&bK05 *P03`0*f&bKP #7 `sp_MScheckmetadatamatcht05*!B/-<6f&bK<sp_MScheckmetadatamathD05*[%0+ f&bK@05*E*!0f&bK create procedure sp_MScheckmetadatamatch (@metatype tinyint, @rowguid uniqueidentifier, @tablenick int, @lineage varbinary(255), @match int output) as select @match = 0 if (@metatype = 3 and not exists (select * from MSmerge_contents where tablenick = @tablenick and rowguid = @rowguid)) select @match = 1 else select @match =count(*) from MSmerge_contents (updlock) where tablenick = @tablenick and rowguid = @rowguid and lineage = @lineage return (0) P05 * 04P05 *05P05 *05405*#705x8x8x ( H@h<\enabled_for_interne c@ 0:DP05T+n7 user_transaction 0:+f&bKt0:+P0: **f&bK(s `bd40:+n70:(@f0D\uei6(2;7(CHECK_OPTION6(2;7(IS_UPDATABLE6(2;7*TABLE_CATALO00;@,7 grrevL0;,\J 04f&bK P0; , 05 40;,70;dV0 0X6 B7*@local_server6 B7"@unc_path6aV/8*TABLE_CATALOG6aV/8$TABLE_NAME6aV/8(TABLE_SCHEMA6aV/8+ .00<D c05(AJVLnJML- 7sp_MSdelrowtx0<-fI05 ?0&JVL$$?@rowguidX0<-tM05  6JVL @rowguid|0<-fJ0<C0&JVL88 C@tablenick\0<-tN0<$6JVL$@tablenick0<-fK0<K0&JVL00K@metadata_typed0<-tM0<,6JVL,@metadata_type0<-fL0<G0&JVLG@lineage_old`0< -tM0<(6JVL(lineage_old0< -fM0< E0&JVL88 E@generation`0< -tM0< &6JVL&@generationt0< -fN0< G0&JVLG@lineage_new`0< -tN0< (6JVL(@lineage_newt0<-fO0 ;0&JVL$$;@pubid T0<-tQ0<6JVL@pubidP0<- +JVL˧i043P0<- 0<JVL@]ytorP0<- 0<JVL000P0<- 0<JVLtorP0<-0<JVL000P0<- 0<JVLf&bK) P0<- 0<JVL= 0<-JVL0<-P0:H0*JVLP  7 Hsp_MSdelrow\0<-!S05$6JVL$sp_MSdelrowD0<-[,05 JVLH./ 7SplitNextD0< .//r@tL0<.GL0<.+G L0<.G+# f0\0< .0<}08YkL}create proc sp_help_fulltext_columns_cursor @cursor_return CURSOR VARYING OUTPUT, @table_name nvarchar(517) = NULL, -- table name @column_name sysname = NULL -- column name as -- FULLTEXT MUST BE ACTIVE IN DATABASE -- if DatabaseProperty(db_name(), 'IsFulltextEnabled') = 0 begin raiserror(15601,-1,-1) return 1 end if @table_name is not null begin -- VALIDATE TABLE NAME -- -- (1) Must exist in current database declare @objid int select @objid = object_id(@table_name, 'local') if @objid is null begin declare @curdbname sysname select @curdbname = db_name() raiserror(15009,-1,-1 ,@table_name, @curdbname) return 1 end -- (2) Must be a user table (and not a temp table) if ObjectProperty(@objid, 'IsUserTable') = 0 OR substring(parsename(@table_name,1),1,1) = '#' begin raiserror(15218,-1,-1 ,@table_name) return 1 end -- VALIDATE COLUMN NAME (CANNOT BE COMPUTED) -- if @column_name is not null begin declare @typename sysname select @typename = type_name(ColumnProperty(@objid, @column_name, 'SystemType')) if @typename is null OR ColumnProperty(@objid, @column_name, 'IsComputed') = 1 begin raiserror(15104,-1,-1,@table_name,@column_name) return 1 end end end set @cursor_return = CURSOR LOCAL SCROLL DYNAMIC FOR select susr.name as TABLE_OWNER, sobj.name as TABLE_NAME, scol.colid as FULLTEXT_COLID, scol.name as FULLTEXT_COLUMN_NAME from sysobjects as sobj, sysusers as susr, syscolumns as scol where ( @table_name is null or sobj.id = @objid ) and scol.id = sobj.id and sobj.uid = susr.uid and ( @column_name is null or scol.name = @column_name ) and ColumnProperty(sobj.id, scol.name, 'IsFullTextIndexed') = 1 order by TABLE_OWNER, TABLE_NAME, FULLTEXT_COLID open @cursor_return -- SUCCESS -- return 0 -- sp_help_fulltext_columns_cursor <0<! .0<x8L0<".))/JVLaP0<# . 0;40<. 70<V00<-0<!0JVL create PROCEDURE sp_MSdelrow (@rowguid uniqueidentifier, @tablenick int, @metadata_type tinyint, /*0 - Missing, 1 - Tombstone, 2 - Contents, 3 - ContentsDeferred */ @lineage_old varbinary(255), @generation int, @lineage_new varbinary(255), @pubid uniqueidentifier = NULL) as set nocount on declare @success int declare @tablename nvarchar(266) declare @rowguidstr nvarchar(40) declare @match int declare @new_metatype tinyint declare @retcode smallint declare @reason nvarchar(255) declare @procname nvarchar(266) declare @ownername sysname /* ** Check to se if current publication has permission */ exec @retcode=sp_MSreplcheck_connection @tablenick = @tablenick if @retcode<>0 or @@ERROR<>0 return (1) select @success = 0 /* Parameter validation */ if (@rowguid is null) begin RAISERROR(14043, 16, -1, '@rowguid') return (0) end if (@tablenick is null) begin RAISERROR(14043, 16, -1, '@tablenick') return (0) end exec @retcode = dbo.sp_MStablenamefromnick @tablenick, @tablename output, @pubid if @@ERROR<>0 return (0) if (@tablename is null) begin RAISERROR(14043, 16, -1, '@tablename') return (0) end if (@lineage_new is null) begin RAISERROR(14043, 16, -1, '@lineage_new') return (0) end if (not exists(select * from sysobjects where name = 'MSmerge_contents')) begin RAISERROR(20054 , 16, -1) return (0) end set @rowguidstr = '''' + convert(nchar(36), @rowguid) + '''' -- Are we just changing the type of a tombstone? if (@metadata_type = 5 and exists (select * from MSmerg_tombstone where rowguid = @rowguid and tablenick = @tablenick)) begin set @reason = formatmessage (20563) -- Moved out of partial range update MSmerge_tombstone set type = @metadata_type, reason = @reason where rowguid = @rowguid and tablenick = @tablenick set @success = 1 return @success end -- Are we just changing the type of a tombstone? if (@metadata_type = 6 and exists (select * from MSmerge_tombstone where rowguid = @rowguid and tablenick = @tablenick)) begin et @reason = formatmessage (20564) -- System deleted update MSmerge_tombstone set type = @metadata_type, reason = @reason where rowguid = @rowguid and tablenick = @tablenick set @success = 1 return @success end -- begin transaction and lock row that we plan to delete begin transaction select @ownername = user_name(uid) from sysobjects where id = object_id(@tablename) select @procname = select_proc from sysmergearticles where objid = object_id(@tablename) and pubid = @pubid exec @retcode = @procname @type =8, @rowguid=@rowguid /* execute ('if not exists (select * from ' + @tablename + '(UPDLOCK) where rowguidcol = ' + @rowguidstr + ') RAISERROR(20031 , 16, -1) ') */ select @success = 2 if @metadata_type = 5 begin set @match = 1 set @new_metatype = 5 end else if @metadata_type = 6 begin set @match = 1 set @new_metatype = 6 end else begin exec @retcode=sp_MScheckmetadatamatch @metadata_type, @rowguid, @tablenick, @lneage_old, @match output set @new_metatype = 1 end if (@match = 1) begin /* execute ('delete from ' + @tablename + ' where rowguidcol = ' + @rowguidstr) */ /* ** select_proc makes a delete with @type = 5, despite its name. */ exec @retcode = @procname @type =5, @rowguid=@rowguid if (@@error = 0 and @@rowcount = 1) begin exec dbo.sp_MSsetrowmetadata @tablenick, @rowguid, @generation, @lineage_new, NULL, @new_metatype select @success = 1 end else select @success = 3 end commit return (@success) P0<& - 0<$P0<' -0<'P0<( -0<( P0<) -0<)40<- 70<́CV0-0-,,@,Dt8 4 X  p 0@Lx8P \/@u7 grrevblL/ /QO8 P/  / 4/u7/dV0V0X @cmd ) fetch hCucount into @aname, @conflict_table end close hCucount deallocate hCucount update #conflict_list set conflicts_ucount = isnull( ul.conflicts_ucount, 0 ) x i se e  <@00TDP0</T/O7 user_transaction 0T/JVLt0T/P0T **JVLmaxr H@J40T/O70T(@f0D\maxrows|/e/C0&+vC988 C@tab00U@07 grrevtL0U0\P 0;JVL P0U 0 0<* 40U070UdV0&0Xguid/e/O0&+vC9O@tablenotbelongseh/ g/06+vC9(d/00VD c0<(AnJM>NT157 sp_MSsetartprocs0V1fV0<G0&nJMG@publication`0V1tZ0<(6nJM(@publicationx0V1fW0V?0&nJM?@articleX0V1tZ0V 6nJM @article0V1fX0VE0&nJM88 E@force_flagg n`0V1t[0V&6nJM&@force_flagelP0V11 0<nJMe(20P0V 11 0V nJM!owcP0V 110V nJM0),P0V 11 0V nJMowgP0V 11 0V nJM = P0V 16 0V nJMoguiP0V17 0VnJMxټqlinP0V15 0VnJMNrinP0V14 0VnJM5IstrP0V14 0VnJM <>P0V14 0VnJM 0V1nJM40V1P$0TR0*nJMP 97 Rsp_MSsetartprocsh0V1]/ .6nJM.sp_MSsetartprocsD0V1[30< nJM0V1H+.0nJM -- Call by snapshot create procedure sp_MSsetartprocs (@publication sysname, @article sysname, @force_flag int = 0) as declare @ownername sysname declare @objectname sysname declare @guidstr nvarchar(40) declare @pubidstr nvarchar(40) declare @ins_procname sysname declare @sel_procname sysname declare @upd_procname sysname declare @view_selprocname sysname declare @viewname sysname declare@artid uniqueidentifier declare @pubid uniqueidentifier declare @objid int declare @rgcol sysname declare @sync_objid int declare @retcode smallint declare @dbname sysname declare @command nvarchar(1000) set nocount on /* ** Check to see if current publication has permission */ exec @retcode=sp_MSreplcheck_publish if @retcode<>0 or @@ERROR<>0 return (1) -- figure out pubid and artid if @force_flag = 1 begin -- don't qualify that must be publisher when we are orcing remake at subscribers select @pubid = pubid from sysmergepublications where name = @publication end else select @pubid = pubid from sysmergepublications where name = @publication and UPPER(publisher)=UPPER(@@SERVERNAME) and publisher_db=db_name() if @pubid IS NULL BEGIN RAISERROR (20026, 16, -1, @publication) RETURN (1) END select @artid = artid, @objid = objid, @sync_objid = sync_objid FROM sysmergearticles WHERE name = @article AND pubid = @pubi if @artid IS NULL BEGIN RAISERROR (20027, 16, -1, @article) RETURN (1) END /* Drop the article procs if they preexist */ exec @retcode = dbo.sp_MSdroparticleprocs @pubid, @artid if @@ERROR<>0 OR @retcode<>0 begin return (1) end -- get owner name, and table name select @objectname = name, @ownername = user_name(uid) from sysobjects where id = @objid -- make the insert and update proc names exec @retcode = dbo.sp_MSguidtostr @artid,@guidstr out if @@ERROR <>0 OR @retcode <>0 return (1) exec @retcode = dbo.sp_MSguidtostr @pubid, @pubidstr out if @@ERROR <>0 OR @retcode <>0 return (1) select @ins_procname = 'sp_ins_' + substring(@guidstr, 1, 16) + substring(@pubidstr, 1, 16) exec dbo.sp_MSuniqueobjectname @ins_procname, @ins_procname output if @@ERROR <>0 OR @retcode <>0 return (1) select @upd_procname = 'sp_upd_' + substring(@guidstr, 1, 16) + substring(@pubidstr, 1, 16) exec dbo.sp_MSuniqueobjectname @upd_procnme, @upd_procname output if @@ERROR <>0 OR @retcode <>0 return (1) select @sel_procname = 'sp_sel_' + substring(@guidstr, 1, 16) + substring(@pubidstr, 1, 16) exec dbo.sp_MSuniqueobjectname @sel_procname, @sel_procname output if @@ERROR <>0 OR @retcode <>0 return (1) set @view_selprocname = 'sel_' + substring(@guidstr, 1, 16) + substring(@pubidstr, 1, 16) exec @retcode = dbo.sp_MSuniqueobjectname @view_selprocname , @view_selprocname output if @retcode <> 0 or @@ERROR <> 0 return (1 -- create the procs set @dbname = db_name() set @command = 'sp_MSmakeinsertproc ' + QUOTENAME(@objectname) + ' , ' + QUOTENAME(@ownername) + ' , ' + @ins_procname + ', [' + convert(nchar(36), @pubid) + ']' exec @retcode = master..xp_execresultset @command, @dbname if @@ERROR<>0 OR @retcode<>0 begin return (1) end exec @retcode = dbo.sp_MS_marksystemobject @ins_procname if @@ERROR<>0 return (1) exec ('grant exec on ' + @ins_procname + ' to public') set @command = 'p_MSmakeupdateproc ' + QUOTENAME(@objectname) + ' , ' + QUOTENAME(@ownername) + ' , ' + @upd_procname exec @retcode = master..xp_execresultset @command, @dbname if @@ERROR<>0 OR @retcode<>0 begin return (1) end exec @retcode = dbo.sp_MS_marksystemobject @upd_procname if @@ERROR<>0 return (1) exec ('grant exec on ' + @upd_procname + ' to public') set @command = 'sp_MSmakeselectproc ' + QUOTENAME(@objectname) + ' , ' + QUOTENAME(@ownername)+ ' , ' + @sel_procname exec in H2/97SplitNextD0V 20</lec@ * L0V2HL0V2H0V i NL0V2+6/Hgenad 0V20V0q}_M-- Creation of sp_describe_cursor Create Procedure sp_describe_cursr ( @cursor_return CURSOR VARYING OUTPUT, @cursor_source nvarchar (30), @cursor_identity nvarchar (128) ) AS declare @scope int /* Check if the cursor exists by name or handle. */ If cursor_status ( @cursor_source, @cursor_identity ) >= -1 begin if lower(convert(varchar(30), @cursor_source)) = 'local' OR lower(convert(varchar(128), @cursor_source)) = 'variable' select @scope = 1 else if lower(convert(varchar(30), @cursor_source)) = 'global' select @scope = 2 set @ursor_return = CURSOR LOCAL SCROLL DYNAMIC FOR SELECT reference_name, cursor_name, cursor_scope, status, model, concurrency, scrollable, open_status, cursor_rows, fetch_status, column_count, row_count, last_operation, cursor_handle FROM master.dbo.syscursorrefs scr, master.dbo.syscursors sc WHERE scr.cursor_scope = @scope and scr.reference_name = @cursor_identity and scr.cursor_handl = sc.cursor_handle ORDER BY 3, 1 FOR READONLY open @cursor_return end 0yM CREATE PROCEDURE sp_MSactivate_auto_sub ( @publication sysname, /* Publication name */ @article sysname ) AS SET NOCOUNT ON DECLARE @retcode int /* ** Security Check. */ exec @retcode = dbo.sp_MSreplcheck_publish if @@ERROR <> 0 or @retcode <> 0 return(1) /* ** Check to see if the database has been activated for publication. */ IF (SELECT category & 1 ROM master..sysdatabases WHERE name = DB_NAME()) = 0 BEGIN RAISERROR (14013, 16, -1) RETURN (1) END /* ** Parameter Check: @publication. ** Make sure that the publication exists and the publication is not push type */ IF @publication IS NULL BEGIN RAISERROR (14043, 16, -1, '@publication') RETURN (1) END EXECUTE @retcode = dbo.sp_validname @publication IF @@ERROR <> 0 OR @retcode < 0 RETURN (1) BEGIN TRAN UPDATE syspublications SET immediate_sync_ready = 1 WHERE name = @publication AND immediate_sync = 1 AND immediate_sync_ready <> 1 IF @@ERROR <> 0 BEGIN GOTO UNDO RETURN (1) END EXECUTE @retcode = dbo.sp_changesubstatus @publication = @publication, @article = @article, @status = 'active', @from_auto_sync = 1 IF @@ERROR <> 0 R @retcode <> 0 BEGIN GOTO UNDO RETURN (1) END COMMIT TRAN RETURN(0) UNDO: IF @@TRANCOUNT = 1 ROLLBACK TRAN ELSE COMMIT TRAN <0V 2H0V, x8L0V2),0<#nJMP0V 2 0U40V2970VV00V100nJM(@command) if @@ERROR<>0 begin return (1) end exec @retcode = dbo.sp_MS_marksystemobject @sel_procname if @@ERROR<>0 return (1) exec ('grant exec on ' + @sel_procname + ' to public') if @sync_objid <> 0 begin select @ownername = user_name(uid), @viewname = name from sysobjects where id = @sync_objid select @rgcol = QUOTENAME(name) from syscolumns where id = @objid and ColumnProperty(id, name, 'isrowguidcol') = 1 exec dbo.sp_MSmakeviewproc @viewname, @ownername, @view_selprocname, @rgcol if @@ERROR<>0 begin return (1) end end else set @view_selprocname = '' -- update articles to set the names update sysmergearticles set insert_proc = @ins_procname, update_proc = @upd_procname , select_proc = @sel_procname, view_sel_proc = @view_selprocname where artid = @artid and pubid = @pubid IF @@ERROR<>0 return (1) return (0) OR(P0V# 1 0V!P0V$ 0V$P0V% 10V% P0V& 10V&40V1970V ,'..@.--%%T%%$h@\`p 0@`0\id) + '''' create table #cont (tablenick int NOT NULL, rowguid uniqueidentifier NOT NULL, generation int NULL, lineage varbinary1VO>F cos)a df 00nDP$0Vx8T3{7 user_transaction 0n3nJMt0n3P$0n **nJMecue ( R Tck,40n3{70n(@f0D\ @tablename + ' t, ' + @temp_cont + ' c where (c.tablenick = ' + @tnstring + ' and c.rowguid > ' + @rgstring + ' and 00o@47 grrev =L0o4\U 0UnJM P0o 4 0V' 40o470odV0X0XOR<>0 or @retcode<>0 RETURN (1) drop table #cont return (0) rP/  /P/ /0pD c0V(A>NJ2O`5\7,sp_MSmakesystableviews0p5+ G0&>NG@publication`0p5tc0V(6>N(@publicationP0p5R 0V>NerP0p5S 0p>NoP0p5T 0p>Nxټq 0p5>N40p5P+0n^0*>NP \7 ^sp_MSmakesystableviewst0p 5"0+:6>N:sp_MSmakesystableviewsliD0p 5[:0V >NTp 50V0>N -- Used by snapshot create procedure sp_MSmakesystableviews (@publication sysname) AS declare @guidstr nvarchar(40) declare @pubid uniqueidentifier declare @contentsview sysname declare @tombstoneview sysname declare @genhistoryview sysname declare @filtersview sysname declare @retcode smallint /* ** Check to see if current publication has permission */ exec @retcode=sp_MSreplcheck_publish if @retcode<>0 or @@ERROR<>0 return (1) select @pubid = pubid from sysmergepublications where name = @publication and UPPER(publisher)=UPPER(@@SERVERNAME) and publisher_db=db_name() if @pubid is null BEGIN RAISERROR (20026, 16, -1, @publication) RETURN (1) END exec @retcode = dbo.sp_MSguidtostr @pubid, @guidstr out if @@ERROR<>0 OR @retcode<>0 return (1) select @contentsview = 'cont' + @guidstr select @tombstoneview = 'ts' + @guidstr select @genhistoryview = 'gh' + @guidstr select @filtersview = 'filt' + @guidstr set @guidstr = '''' + convert(nchar(36), @pubid) + '''' exec @retcode = dbo.sp_MSuniqueobjectname @tombstoneview, @tombstoneview out if @@ERROR<>0 OR @retcode<>0 return (1) exec @retcode = dbo.sp_MSuniqueobjectname @contentsview, @contentsview out if @@ERROR<>0 OR @retcode<>0 return (1) exec @retcode = dbo.sp_MSuniqueobjectname @genhistoryview, @genhistoryview out if @@ERROR<>0 OR @retcode<>0 return (1) exec @retcode = dbo.sp_MSuniqueobjectname @filtersview, @filtersview out if @@ERROR<>0 OR @retcode<>0 return (1) /* generate view for MSmerge_contents qualified by the pubid */ exec ('create view ' + @tombstoneview + ' as select * from MSmerge_tombstone where tablenick in (select nickname from sysmergearticles where convert(nchar(36), pubid) = ' + @guidstr + ')') if @@ERROR <>0 begin return (1) end exec ('create view ' + @contentsview + ' as select * from MSmerge_contents where tablenick in (select nickname from sysmergearticles where convert(nchar(36), pubid) = ' + @guidstr + ')' ) if @@ERROR <>0 begin return (1) end exec ('create view ' + @genhistoryview + '(guidsrc, guidlocal, pubid, generation, art_nick, nicknames, coldate) as select DISTINCT guidsrc, guidlocal, CONVERT(uniqueidentifier, ' + @guidstr + '), generation, art_nick, nicknames, coldate from MSmerge_genhistory where guidlocal <> ''00000000-0000-0000-0000-000000000000'' and (art_nick = 0 or art_nick is NULL or art_nick in (select nickname from sysmergearticles where convert(nchar(36), pubid) = ' + @guidstr + ')) ') if @@ERROR <>0 begin return (1) end exec ('create view ' + @filtersview + ' as select * from sysmergesubsetfilters where convert(nchar(36), pubid) = ' + @guidstr) if @@ERROR <>0 begin return (1) end set nocount on select @contentsview, @tombstoneview, @genhistoryview, @filtersview return (0) P0p 5 0oP0p 50p P0p 0p P0p 50p40p5\70ṕCV0@PD<<\X/?/ 6< @lineaget//90&<9@colvid T/>/6<500DP+0p T67 user_transaction 06>Nt06P+0 **>N ^`40670(@f0D\C /<R iP/C /<00@77 grrevL07\Z 0o>N P0 7 0p 40770dV0U0X!Z/ <H/7SplitNextD/# //k!@L/ 0D c0p(AJ2O&P\87&sp_MSgetchangecount|080pA0&J2O88 A@startgenea\08tn0p"6J2O"@startgen x080?0&J2O88 ?@changescX08tn0 6J2O @changesx080?0&J2O88 ?@updatesaX08tp0 6J2O @updatesx080?0&J2O88 ?@deletesVX0 8to0 6J2O @deletes 0 8J2O0 8P10X0*J2OP 7 Xsp_MSgetchangecountl0 8Y=046J2O4sp_MSgetchangecountD0 8[A0p  J2O08I+l 0J2O create procedure sp_MSgetchangecount( @startgen int, @changes int output, @updates int output, @deletes int output) as select @deletes = count(*) from MSmerge_tombstone where generation = 0 or generation > @startgen select @updates = count(*) from MSmerge_contents where generation = 0 or generation > @startgen select @changes = @updates + @deletes return (0) P0 8 0P0 80P0 8040870x8x8(8` 0`4\in raiserror(15090,-1,-1) return (1) end end -- ADD THE SERVER (CHECKS PERMISSIONS, ETC) execute @retcode = sp_addlinkedserver @server  0DP10 T97 user_transaction 09J2Ot09P10 **J2Osmal XtZ--40970(@f0D\ BY sp_addlinkedserver select @srvid = srvid from master.db00@:7 grrevtL0:\_ 0J2O P0 : 0 40:70dV0&0Xvid = 0, schemadate = getdate() where srvname = @server end -- FOR COMPATIB 0D c0(A&PQL;n7sp_MSbelongs|0;0 C0&&PC@publisher \0;tx0 $6&P$@publisher0;0I0&&PI@publisher_dbted0;ty0*6&P*@publisher_db'0;0G0&&PG@publication `0;tx0(6&P(@publication|0;0C0&&P88 C@tablenickr\0 ;t{0$6&$@tablenickx0 ;0 ?0&&P$$?@rowguidEX0 ;t{0  6&P @rowguidx0 ; 0 =0&&P88 =@retval/ X0 ;t{0 6&P@retval x0;!0 =0&&P8 =@nested_suX0;tx06&P@nestedh_P0;z 0p&P@]y da 0;&P40;P80J0*&PP n7 Jsp_MSbelongsis`0;!;0<&6&P&sp_MSbelongs**D0;[H0 &PH</n7SplitNextD0 <0V/ @ *L0<ML0<M+s"AI (L0<+MD  L p(8h Hh$\ EXECUTE @retcode = dbo.sp_valid8P )* 00<00[PCREATE PROCEDURE sp_MSaddpub_snapshot ( @publication sysname, @freqtype int = 4 , /* 4== Daily */ @freqinterval int = 1, /* Every day */ @freqsubtype int = 4, /* Sub interval = Minute */ @freqsubinterval int = 5, /* Every five minutes */ @freqrelativeinterval int = 1, @freqrecurrencefactor int = 0, activestartdate int = 0, /* 12:00 am - 11:59 pm */ @activeenddate int =99991231 , /* No start date */ @activestarttimeofday int = 0, @activeendtimeofday int = 235959, /* No end time */ @newagentid int = 0 OUTPUT ) AS SET NOCOUNT ON /* ** Declarations. */ DECLARE @retcode int DECLARE @distributor sysname DECLARE @distribdb sysname DECLARE @distproc nvarchar (255 DECLARE @agentname nvarchar(100) DECLARE @database sysname DECLARE @newid int DECLARE @mergepublish_bit smallint DECLARE @centralpublish_bit int DECLARE @fFoundPublication int DECLARE @agent_args nvarchar(4000) DECLARE @snapshot_jobid binary(16) DECLARE @dist_rpcname sysname DECLARE @publication_type int /* ** Initializations */ select @mergepublish_bit = 4 select @centrlpublish_bit = 1 select @fFoundPublication = 0 EXEC @retcode = dbo.sp_helppublication @publication, @fFoundPublication output IF @@ERROR <> 0 OR @retcode <> 0 BEGIN RETURN (1) END IF @fFoundPublication = 0 BEGIN SELECT @newagentid = 0 RETURN (0) END /* ** Make sure the publication does not already have a agent. */ IF EXISTS (SELECT * FROM syspublications WHERE name = @publication and napshot_jobid <> NULL) BEGIN RAISERROR (14101, 11, -1, @publication) RETURN(1) END /* Get publication_type */ SELECT @publication_type = repl_freq from syspublications WHERe name = @publication /* ** Get distributor information */ EXEC @retcode = dbo.sp_helpdistributor @distributor = @distributor OUTPUT, @distribdb = @distribdb OUTPUT, @rpcsrvname = @dist_rpcname OUTPUT IF @@error <> 0 OR @retcode <> 0 or @distributorIS NULL OR @distribdb IS NULL BEGIN RAISERROR (14071, 16, -1) RETURN (1) END SELECT @database = DB_NAME() SELECT @distproc = RTRIM(@dist_rpcname) + '.' + @distribdb + '.dbo.sp_MSadd_snapshot_agent' SELECT @agent_args = '-Publisher ' + QUOTENAME(@@SERVERNAME) SELECT @agent_args = @agent_args + ' -PublisherDB ' + QUOTENAME(@database) SELECT @agent_args = @agent_args + ' -Distributor ' + QUOTENAME(@distributor) SELECT @agent_args = @agent_arg + ' -Publication ' + QUOTENAME(@publication) BEGIN TRAN EXECUTE @retcode = @distproc @publisher = @@SERVERNAME, @publisher_db = @database, @publication = @publication, @publication_type = @publication_type, @local_job = 1, @freqtype = @freqtype, @freqinterval = @freqinterval, @freqsubtype = @freqsubtype, @freqsubinterval = @freqsubinterval, @freqrelativeinterval = @freqrelativeinterval, @freqrecurrencefactor = @freqrecurrencefactor, @activestartdate = @activestartdate, @activeenddate = @activeenddate, @activestarttimeofday = @activestarttimeofday, @activeendtimeofday = @activeendtimeofday, @command = @agent_args, @snapshot_jobid = @snapshot_jobid OUTPUT IF @@ERROR <> 0 or @retcode <> 0 GOTO UNDO -- Legacy, use non zero taskid to indicate agent already created at the distributor. UPDATE syspublicatins set sX0[Pnapshot_jobid = @snapshot_jobid WHERE name = @publication IF @@ERROR <> 0 GOTO UNDO -- This is the output parameter to indicate agent created. SELECT @newagentid = 1 COMMIT TRAN return (0) UNDO: if @@TRANCOUNT = 1 ROLLBACK TRAN else COMMIT TRAN return(1) <0 <M0x8L0<)30V [PP0 < 040<n70V00;M00&P -- Modify temp table. No security check needed. create procedure sp_MSbelongs @publisher sysname, @publisher_db sysname, @publication sysname, @tablenick int, @rowguid uniqueidentifier, @retval int output, @nested int = 0 AS declare @artid uniqueidentifier declare @join_guid uniqueidentifier declare @last_joinid int declare @join_id int declare @join_nick int declare @probe_id int declare @last_probe int declare @join_nickstr nvarchar(10) declare @pubid uniqueidentifier declare @guidstring nvarchar(38) declare @subset_filter nvarchar(4000) declare @tablename nvarchar(266) declare @join_table nvarchar(266) declare @boolean nvarchar(4000) declare @retcode smallint select @pubid = pubid from sysmergepublications where name = @publication and UPPER(publisher)=UPPER(@publisher) and publisher_db=@publisher_db /* Check for case of all rows - do I trust subset_type ? */ select @boolean subset_filterclause, @artid = artid from sysmergearticles where pubid = @pubid and nickname = @tablenick if ((@boolean is null or @boolean = ' ') and not exists (select * from sysmergesubsetfilters where art_nickname = @tablenick)) begin set @retval = 0 return end if @nested = 0 begin create table #found (flag int NOT NULL) insert into #found values (0) create table #probe (probe_id int identity NOT NULL, tablenick int NOT NULL, rowguid uniqueidentifier ROWGUIDCOLdefault newid() not null, tested int NOT NULL) set @last_probe = 0 end else begin select @last_probe = max(probe_id) from #probe end /* pubid is already available */ exec @retcode = dbo.sp_MStablenamefromnick @tablenick, @tablename out, @pubid if @@ERROR<>0 or @retcode<>0 return (1) set @guidstring = '''' + convert(nchar(36), @rowguid) + '''' /* If there is boolean filter, check for it being satisfied */ if @boolean is not null and @boolean <> ' ' begin exec ('f exists (select * from ' + @tablename + ' where rowguidcol = ' + @guidstring + ' and (' + @boolean + ')) update #found set flag = 1') if @@ERROR<>0 return (1) select @retval = flag from #found if @retval = 1 goto EndLabel end /* Loop over join filters, populating #probe */ select @join_id = min(join_filterid) from sysmergesubsetfilters where pubid = @pubid and art_nickname = @tablenick while @join_id is not null begin select @boolean = join_filterclause, @join_nick = join_nikname from sysmergesubsetfilters where pubid = @pubid and join_filterid = @join_id exec @retcode = dbo.sp_MStablenamefromnick @join_nick, @join_table out, @pubid if @@ERROR<>0 or @retcode<>0 return (1) set @join_nickstr = convert(nchar(10), @join_nick) /* execute a query to put these into the #probe table */ exec ('insert into #probe (tablenick, rowguid, tested) select distinct ' + @join_nickstr + ', ' + @join_table + '.rowguidcol, 0 from ' + @tablename + ', ' + @join_table + ' where ' + @tablename + '.rowguidcol = ' + @guidstring + ' and (' + @boolean + ') and not exists (select * from #probe where tablenick = ' + @join_nickstr + ' and rowguidcol = ' + @join_table + '.rowguidcol) ' ) if @@ERROR<>0 begin return (1) end /* get to next join filter and repeat */ set @last_joinid = @join_id select @join_id = min(join_filterid) from sysmergesubsetfilters where pubid = @pubid and art_nickname = @tablenick and join_filterid > @last_joinid end / Loop over probe, making recursive call */ select @probe_id = min(probe_id) from #probe where probe_id > @last_probe and tested = 0 while @probe_id is not null begin select @join_nick = tablenick, @join_guid = rowguidcol from #probe where probe_id = @probe_id set @last_probe = @probe_id /* update tested flag on this row so we don't try it again while recursing */ update #probe set tested = 1 where probe_id = @probe_id /* Make recursive call. If it b4 h0;M0/0&P/elongs, we are done. */ exec @retcode = dbo.sp_MSbelongs @publisher, @publisher_db, @publication, @join_nick, @join_guid, @retval output, 1 if @@ERROR<>0 OR @retcode<>0 begin return (1) end if @retval = 1 goto EndLabel /* get next probe_id and repeat */ select @probe_id = min(probe_id) from #probe where probe_id > @last_probe and tested = 0 end /* All Done, delete temps if not nested */ EndLabel: if @nested = 0 begin drop table #found drop table #probe end return bP0 ; 0P0 ;0P0 ;0 P0 ;0 40;n70Mae)<)((L(#p$@lineage,* ci = o s sa)@*0DP80/T=7 user_transaction 0=&Pt0=P80 **&P row JdLro40=70(@f0D\< datalength(@cvcurrent)) set @colv = @cvcurrent /* I00@>7 grreveL0>\e 0&P P0 > 0 40>70dV0i0Xhere tablenick = @tablenick and rowguid = @rowguid and (partchangegen is null or partchangegen <>  6 0D c0(AQ#RX?7$sp_MSexpandbelongst0?R0;0&Q$$;@pubid T0?t06Q@pubid 0?Q0?P?0V0*QP 7 Vsp_MSexpandbelongsdl0?Y%0 26Q2sp_MSexpandbelongsoD0?[O0 Q0?L+0Q -- Modify temp table. No security check needed. create procedure sp_MSexpandbelongs @pubid uniqueidentifier AS declare @filterid int declare @retval int declare @expand_proc sysname /* We iterat over the join filters */ select @filterid = min(flag) from #belong select @filterid = min(join_filterid) from sysmergesubsetfilters where pubid = @pubid and join_filterid > @filterid and exists (select * from #belong where tablenick = join_nickname and flag < join_filterid) while (@filterid is not null) begin select @expand_proc = expand_proc from sysmergesubsetfilters where pubid = @pubid and join_filterid = @filterid exec @retval = @expand_proc @belong = 1 if @retval <> 0 retun (1) select @filterid = min(join_filterid) from sysmergesubsetfilters where pubid = @pubid and join_filterid > @filterid and exists (select * from #belong where tablenick = join_nickname and flag < join_filterid) end return (0) P0 ? 0P0 ?0 P0 ?0 40?70x8x8H,|(\0/.hTp7 user_transaction /B=t/BU0/B **=d X Z('d4/Bp7/B(@f0D\wner) = 1) begin raiserror(15000,-1,-1) return (1) end -- ERROR IF ROLE NOT FOUND -- if @uid is re 0DP?0T@7 user_transaction 0@Qt0@P?0 **Q VsXt *40@70(@f0D\rror(15144,-1,-1) select name = user_name(memberuid) from sysmembers where groupuid = @uid return (1) end 00@A+7 grrev>L0A\k 0Q P0 A 0 40A+70dV0"0XcEX/D`/. 6H+> @guidsrcp/D//D70&H+>88 7@genP F 0D c0(A#R.HS`B7*sp_MSexpandnotbelongsit0B+;0&#R$$;@pubidT0B+6#R@pubid 0B#R0BPF0\0*#RP 7 \sp_MSexpandnotbelongsp0BY&086#R8sp_MSexpandnotbelongsD0B[V0 #R0B+0#R -- Modify temp table. No security check needed. create procedure sp_MSexpandnotbelongs @pubid uniqueidentifier AS declare @filterid int declare @retval int declare @expand_proc sysnme /* We iterate over the join filters */ select @filterid = min(flag) from #notbelong select @filterid = min(join_filterid) from sysmergesubsetfilters where pubid = @pubid and join_filterid > @filterid and exists (select * from #notbelong where tablenick = join_nickname and flag < join_filterid) while (@filterid is not null) begin select @expand_proc = expand_proc from sysmergesubsetfilters where pubid = @pubid and join_filterid = @filterid exec @retval = @expand_proc @belong 0 if @retval <> 0 return (1) select @filterid = min(join_filterid) from sysmergesubsetfilters where pubid = @pubid and join_filterid > @filterid and exists (select * from #notbelong where tablenick = join_nickname and flag < join_filterid) end P0 B 0P0 B0 P0 B0 40B70CX0X80\ update MSmerge_genhistory set generation = 1 where guidsrc = @guidsrc set @gen = 1 end if @saverr = 0 begin /* Now put in rows for other publications that share articles with this one */ insert into MSmerge_genhistory (guidsrc, pubid, guidlocal, generation, nicknames, coldate) select distinct @guidsrc, pubid, '00000000-0000-0000-0000-000000000000', @gen, 0x0, @dt from sysmergearticles where pubid <> @pu=a 0DPF0TC 7 user_transaction 0C#Rt0CPF0 **#R \^40C 70(@f0D\P/D /D P/D 00@DW 7 grrevL0D\p 0#R P0 D 0 40DW 70dV0[0X \^4.6.(@Q0D\P X.P4.IX6.Inef /CYZ0D c0(A.HSglSXE 7"sp_MSsetupbelongs |0E0C0&.HSC@publisher\0E0$6.HS$@publisher0E0I0&.HSI@publisher_dbd0E0*6.HS*@publisher_db0E0G0&.HSG@publication`0E0(6.HS(@publicationx0E0?0&.HS?@genlistX0 E0 6.HS @genlist|0 E0 C0&.HS88 C@commongen\0 E0 $6.HS$@commongen|0 E0 A0&.HS88 A@subissql\0 E0 "6.HS"@subissqlP0E 0.HSoP0E 0.HSrAP0E 0.HSnP0E 0.HSnP0E 0.HSP0E 0.HSP0E 0.HSP0E 0.HS&PP0E 0.HSQP0E 0.HS#R 0E.HS40EPM0T0*.HSP  7 Tsp_MSsetupbelongsh0E]0V06.HS0sp_MSsetupbelngsD0E[]0 .HSHF/ 7SplitNext80F/V0L0 F0/D0 F0/cod@ in80  F/x8L0!FL0"F+ en L0#F!en 0$F0"0XR8S create procedure sp_MSmark_proc_norepl @procname sysname as set nocount on -- CHECK PERMISSIONS (MUST BE DBO) -- if not (is_member('db_owner')=1 or is_srvrolemember('sysadmin') = 1) begin raiserror(20521,0,1) return 1 end -- CHECK THE OBJECT NAME -- if object_id(@procname, 'local') is null begin raiserror(20522,0,1,@procname) return 1 end -- DO THE UPDATE -- begin tran exec dbo.sp_replupdateschema @procname update sysobjects set replinfo = replinfo | 0x40 where id = object_id(@procname, 'local') commit tran return @@error g0`MScreate procedure sp_create_removable @dbname sysname = null, /* name of db */ @syslogical sysname = null, /* logicl name of system device */ @sysphysical nvarchar (260) = null, /* physical name of system device */ @syssize int = null, /* size of sys device in Meg. */ @loglogical sysname = null, /* logical name of log device */ @logphysical nvarchar (260) = null, /* physical name of log device */ @logsize int = null, /* size of log device in Meg. */ @datalogical1 sysname = null, /* logical name of data device */ @dataphysical1 nvarchar (260) = null, /* physical name of data device */ @datasize1 int = null, / size of data device in Meg. */ @datalogical2 sysname = null, /* logical name of data device */ @dataphysical2 nvarchar (260) = null, /* physical name of data device */ @datasize2 int = null, /* size of data device in Meg. */ @datalogical3 sysname = null, /* logical name of data device */ @dataphysical3 nvarchar (260) = null, /* physical name of data device */ @datasize3 int = null, /* size of data device in Meg. */ @datalogical4 sysname = null, /* logical name of data device */ @dataphysical4 nvrchar (260) = null, /* physical name of data device */ @datasize4 int = null, /* size of data device in Meg. */ @datalogical5 sysname = null, /* logical name of data device */ @dataphysical5 nvarchar (260) = null, /* physical name of data device */ @datasize5 int = null, /* size of data device in Meg. */ @datalogical6 sysname = null, /* logical name of data device */ @dataphysical6 nvarchar (260) = null, /* physical name of data device */ @datasize6 int = null, /* size of data device in Meg. */ datalogical7 sysname = null, /* logical name of data device */ @dataphysical7 nvarchar (260) = null, /* physical name of data device */ @datasize7 int = null, /* size of data device in Meg. */ @datalogical8 sysname = null, /* logical name of data device */ @dataphysical8 nvarchar (260) = null, /* physical name of data device */ @datasize8 int = null, /* size of data device in Meg. */ @datalogical9 sysname = null, /* logical name of data device */ @dataphysical9 nvarchar (260) = null, /* physical nme of data device */ @datasize9 int = null, /* size of data device in Meg. */ @datalogical10 sysname = null, /* logical name of data device */ @dataphysical10 nvarchar (260) = null, /* physical name of data device */ @datasize10 int = null, /* size of data device in Meg. */ @datalogical11 sysname = null, /* logical name of data device */ @dataphysical11 nvarchar (260) = null, /* physical name of data device */ @datasize11 int = null, /* size of data device in Meg. */ @datalogical12 sysname = nul, /* logical name of data device */ @dataphysical12 nvarchar (260) = null, /* physical name of data device */ @datasize12 int = null, /* size of data device in Meg. */ @datalogical13 sysname = null, /* logical name of data device */ @dataphysical13 nvarchar (260) = null, /* physical name of data device */ @datasize13 int = null, /* size of data device in Meg. */ @datalogical14 sysname = null, /* logical name of data device */ @dataphysical14 nvarchar (260) = null, /* physical name of data device * @datasize14 int = null, /* size of data device in Meg. */ @datalogical15 sysname = null, /* logical name of data device */ @dataphysical15 nvarchar (260) = null, /* physical name of data device */ @datasize15 int = null, /* size of data device in Meg. */ @datalogical16 sysname = null, /* logical name of data device */ @dataphysical16 nvarchar (260) = null, /* physical name of data device */ @datasize16 int = null /* size of data device in Meg. */ as declare @retcode int, @exec_str nvarcar (460), @numdevs int if suser_id() <> 1 -- Make sure that it's the SA executing this. begin raiserror(15003,-1,-1, 'sysadmin') return(1) end if @dbname is null or @syslogical is null or @sysphysical is null or @syssize is null or @loglogical is null or @logphysical<0% F0#|x8L0&F)90XR8SP0' F 040F 70V00E0&0.HS -- Modify temp table. No security check needed. create procedure sp_MSsetupbelongs @publisher sysname, @publisher_db sysname, @publication sysname, @genlist varchar(1000), @commongen int, @subissql int AS declare @pubid uniqueidentifier declare @temp_id int declare @retval int declare @tablenick int declare @tnstr nvarchar(12) declare rowguid uniqueidentifier declare @rowguidstr nvarchar(40) declare @belongsname sysname declare @notbelongsname sysname declare @artnick int declare @artnickstr nvarchar(10) declare @artviewobjid int declare @procname sysname declare @artbaseobjid int declare @artviewname sysname declare @artviewowner sysname declare @commongenstr nvarchar(12) declare @partchangegen int declare @joinchangegen int declare @rgcol sysname declare @maxfilterid int declare @view_type int decare @temp_view int declare @retcode smallint /* ** To public */ set @temp_view = 2 select @pubid = pubid from sysmergepublications where name = @publication and UPPER(publisher)=UPPER(@publisher) and publisher_db=@publisher_db set @commongenstr = convert(nchar(12), @commongen) /* Set up the ##belong and ##notbelong tables; return names as rowset */ /* step 1 make temptable names, create tables */ set @rowguid = newid() exec @retcode=sp_MSguidtostr @rowguid, @rowguidstr out if @retcode<>0 or @@ERROR<>0 return (1) set @belongsname = '##belong' + @rowguidstr exec @retcode = dbo.sp_MSuniquetempname @belongsname, @belongsname out IF @@ERROR<>0 OR @retcode<>0 return (1) create table #belong (tablenick int NOT NULL, rowguid uniqueidentifier NOT NULL, flag int NOT NULL, partchangegen int null, joinchangegen int null) create index #indbelong on #belong (rowguid) exec ('create table ' + @belongsname + ' (tablenick int NOT NULL, rowguid uniqueidentifier NOT NULL, generation int NULL, lineage varbinary(255) NULL, colv varbinary(2048) NULL) ') if @@ERROR <>0 return (1) create table #notbelong (bookmark int identity NOT NULL, tablenick int NOT NULL, rowguid uniqueidentifier NOT NULL, flag int NOT NULL, partchangegen int null, joinchangegen int null) create index #indnbelong on #notbelong (tablenick, rowguid) set @notbelongsname = '##notbelong' + @rowguidstr exec @retcode = dbo.sp_MSuniquetempname @notbelongsname, @notbelongsname out IF @@ERROR<>0 OR retcode<>0 return (1) exec ('create table ' + @notbelongsname + ' (tablenick int NOT NULL, rowguid uniqueidentifier NOT NULL, generation int NULL, lineage varbinary(255) NULL, type tinyint NOT NULL) ') if @@ERROR <>0 return (1) create table #temp_cont (temp_id int identity NOT NULL, tablenick int NOT NULL, rowguid uniqueidentifier NOT NULL, partchangegen int null, joinchangegen int null) /* step 2 setup pass through MSmerge_contents */ /* article with permanent views can be handled withbulk inserts */ set @artnick = 0 set rowcount 0 /* Get first article, go into loop */ select @artnick = min(nickname) from sysmergearticles where pubid = @pubid and nickname > @artnick /* Put all relevant changes in #notbelong to start. It simplifies the queries greatly, ** and we can delete out the rows from #belong efficiently at the end. */ exec ('insert into #notbelong (tablenick, rowguid, flag, partchangegen, joinchangegen) select tablenick, c.rowguid, 0, partchangegen, oinchangegen from MSmerge_contents c where generation in (' + @genlist + ')') if @@ERROR <>0 return (1) while (@artnick is not null) begin set @artnickstr = convert(nchar(10), @artnick) select @artviewobjid = sync_objid, @artbaseobjid = objid, @view_type = view_type, @procname = view_sel_proc from sysmergearticles where pubid = @pubid and nickname = @artnick /* Get name of rowguidcol. Aliasing doesn't work through a view. */ select @rgcol = name from syscolumns whereid = @artbaseobjid and ColumnPropertcheHG/ 7SplitNextD0+ G0 /jec@s wL0,G0L0-G0*scxtL0.G0%tisc0/G0-0.HS -- Modify temp table. No ecurity check needed. create procedure sp_MSsetupbelongs @publisher sysname, @publisher_db sysname, @publication sysname, @genlist varchar(1000), @commongen int, @subissql int AS declare @pubid uniqueidentifier declare @temp_id int declare @retval int declare @tablenick int declare @tnstr nvarchar(12) declare @rowguid uniqueidentifier declare @rowguidstr nvarchar(40) declare @belongsname sysname declare @notbelongsname sysname declare @artnick int declare @rtnickstr nvarchar(10) declare @artviewobjid int declare @procname sysname declare @artbaseobjid int declare @artviewname sysname declare @artviewowner sysname declare @commongenstr nvarchar(12) declare @partchangegen int declare @joinchangegen int declare @rgcol sysname declare @maxfilterid int declare @view_type int declare @temp_view int declare @retcode smallint /* ** To public */ set @temp_view = 2 select @pubid = pubid from sysmergepublications where nae = @publication and UPPER(publisher)=UPPER(@publisher) and publisher_db=@publisher_db set @commongenstr = convert(nchar(12), @commongen) /* Set up the ##belong and ##notbelong tables; return names as rowset */ /* step 1 make temptable names, create tables */ set @rowguid = newid() exec @retcode=sp_MSguidtostr @rowguid, @rowguidstr out if @retcode<>0 or @@ERROR<>0 return (1) set @belongsname = '##belong' + @rowguidstr exec @retcode = dbo.sp_MSuniquetempname @belongsname, @belongsname ot IF @@ERROR<>0 OR @retcode<>0 return (1) create table #belong (tablenick int NOT NULL, rowguid uniqueidentifier NOT NULL, flag int NOT NULL, partchangegen int null, joinchangegen int null) create index #indbelong on #belong (rowguid) exec ('create table ' + @belongsname + ' (tablenick int NOT NULL, rowguid uniqueidentifier NOT NULL, generation int NULL, lineage varbinary(255) NULL, colv varbinary(2048) NULL) ') if @@ERROR <>0 return (1) create table #notbelong (bookmark int identity NT NULL, tablenick int NOT NULL, rowguid uniqueidentifier NOT NULL, flag int NOT NULL, partchangegen int null, joinchangegen int null) create index #indnbelong on #notbelong (tablenick, rowguid) set @notbelongsname = '##notbelong' + @rowguidstr exec @retcode = dbo.sp_MSuniquetempname @notbelongsname, @notbelongsname out IF @@ERROR<>0 OR @retcode<>0 return (1) exec ('create table ' + @notbelongsname + ' (tablenick int NOT NULL, rowguid uniqueidentifier NOT NULL, generation int NULL, lineagevarbinary(255) NULL, type tinyint NOT NULL) ') if @@ERROR <>0 return (1) create table #temp_cont (temp_id int identity NOT NULL, tablenick int NOT NULL, rowguid uniqueidentifier NOT NULL, partchangegen int null, joinchangegen int null) /* step 2 setup pass through MSmerge_contents */ /* article with permanent views can be handled with bulk inserts */ set @artnick = 0 set rowcount 0 /* Get first article, go into loop */ select @artnick = min(nickname) from sysmergearticles where puid = @pubid and nickname > @artnick /* Put all relevant changes in #notbelong to start. It simplifies the queries greatly, ** and we can delete out the rows from #belong efficiently at the end. */ exec ('insert into #notbelong (tablenick, rowguid, flag, partchangegen, joinchangegen) select tablenick, c.rowguid, 0, partchangegen, joinchangegen from MSmerge_contents c where generation in (' + @genlist + ')') if @@ERROR <>0 return (1) while (@artnick is not null) begin set @artnickstr = convert(nchar(10), @artnick) select @artviewobjid = sync_objid, @artbaseobjid = objid, @view_type = view_type, @procname = view_sel_proc from sysmergearticles where pubid = @pubid and nickname = @artnick /* Get name of rowguidcol. Aliasing doesn't work through a view. */ select @rgcol = name from syscolumns where id = @artbaseobjid and ColumnPropertRRO<00 G0.x8L01G)90'.Hn P02 G 0(40+G 70+V00*E000.HSy(@artbaseobjid, name, 'isrowguidcol') = 1 /* UNDONE get view type from sysmergearticle to see if permanent view to use */ set @artviewname = NULL if @view_type <> @temp_view select @artviewname = name, @artviewowner = user_name(uid) from sysobjects where id = @artviwobjid if (@procname is not null) begin exec @retcode = @procname @artnick if @@ERROR <>0 or @retcode <> 0 return (1) end else begin delete from #temp_cont exec ('insert into #temp_cont (tablenick, rowguid, partchangegen, joinchangegen) select tablenick, rowguid, partchangegen, joinchangegen from MSmerge_contents where tablenick = ' + @artnickstr + ' and generation in (' + @genlist + ') ') if @@ERROR <>0 return (1) set @temp_id = 0 selec @temp_id = min(temp_id) from #temp_cont where temp_id > @temp_id while (@temp_id is not null) begin select @tablenick = tablenick, @rowguid = rowguid, @partchangegen = partchangegen, @joinchangegen = joinchangegen from #temp_cont where temp_id = @temp_id set @rowguidstr = '''' + convert(nchar(36), @rowguid) + '''' exec @retcode = dbo.sp_MSbelongs @publisher, @publisher_db, @publication, @tablenick, @rowguid, @retval output, 0 if @@ERROR<>0 OR @retcode <>0 i @retval = 1 begin insert into #belong (tablenick, rowguid, flag, partchangegen, joinchangegen) values (@artnick, @rowguid, 0, @partchangegen, @joinchangegen) if @@ERROR <>0 return (1) end else begin /* Checking partchangegen will tell us if we need to insert this */ if @partchangegen > @commongen insert into #notbelong (tablenick, rowguid, flag) values (@artnick, @rowguid, 0) end select @temp_id = min(temp_id) from #tempcont where temp_id > @temp_id end end /* Move on to next article, repeat while loop */ select @artnick = min(nickname) from sysmergearticles where pubid = @pubid and nickname > @artnick end drop table #temp_cont /* Clean up #notbelong by using #belong - we inserted with out really checking */ delete from #notbelong where rowguid in (select rowguid from #belong) delete from #notbelong where partchangegen < @commongen /* Optimization: If joinchangegen and partchangeare both null or < common gen, ** it is not necessary to expand #belong for that particular row. */ select @maxfilterid = max(join_filterid) from sysmergesubsetfilters if @maxfilterid is not null begin update #belong set flag = @maxfilterid where (joinchangegen <= @commongen and (partchangegen is null or partchangegen <= @commongen)) /* Expand the #belong temptable */ exec @retcode = dbo.sp_MSexpandbelongs @pubid if @@ERROR<>0 OR @retcode<>0 return (1) end /* tranfer rows from local temp to global temp */ exec ('insert into ' + @belongsname + ' (tablenick, rowguid, generation, lineage, colv) select b.tablenick, b.rowguid, c.generation, c.lineage, c.colv1 from #belong b left outer join MSmerge_contents c on c.tablenick = b.tablenick and c.rowguid = b.rowguid ') if @@ERROR <>0 return (1) /* If subscriber is sql server, we don't have to expand belongs */ if @subissql = 0 begin /* Expand the #notbelong temptable */ exec dbo.sp_MSexpandntbelongs @pubid end /* transfer rows from local temp to global temp */ exec ('insert into ' + @notbelongsname + ' (tablenick, rowguid, generation, lineage, type) select b.tablenick, b.rowguid, c.generation, c.lineage, 5 from #notbelong b left outer join MSmerge_contents c on c.tablenick = b.tablenick and c.rowguid = b.rowguid ') if @@ERROR <>0 return (1) drop table #notbelong /* Add tombstones to ##notbelong */ exec ('insert into ' + @notbelongsname + ' (tablenick, rowguid,generation, lineage, type) select tablenick, rowguid, generation, lineage, type from MSmerge_tombstone where generatioHH/ 7SplitNextD06 H0,/@L07H0L08H05epntL09H0/* ysL0H):02.HSP0; H 03406H 706V0H05E080.HSn in (' + @genlist + ')') if @@ERROR <>0 return (1) if not exists (select * from #belong) select @belongsname, @notbelongsname, -1 else select distinct @belongsname, @notbelongsname, tablenick from #belong drop table #belong return (0) P0> E 0<P0? E0?P0@ E0@ PA E0A40E 70getLXWW\W WTT@TSS\SSRRB`BBAA1L110p0(08  h,x , \  L   Tdt$x$Tt0\ r/w(6eB(@publication/w I/wO0&eB88 O@datasourc0: os _fteS b Oumas j @ l@h/la@a*a oZ0DPM0TI8!7 user_transaction 0I.HSt0IPM0 **.HSx TV40I8!70(@f0D\?@db_namenX/w  r/w  6eB @db_name/00@J!7 grrevL0J\s 0.HS P0 J 0B 40J!70dV0!0XA@nicknamect \/w r/w"6eB"@nicknamero/w N/wK0&e/ 0D c0(AglST`K"7,sp_MSaddinitialarticlex0K +?0&glS?@articleX0K]0 6glS @articlet0K 0;0&glS$$;@artidBT0K^06glS@artidt0K 0;0&glS$$;@pubidT0K_06glS@pubid|0K 0A0&glS88 A@nickname4\0 K_0"6glS"@nickname0K 0 O0&glS88 O@column_trackinglh0 K_0 06glS0@column_trackingx0 K0 =0&glS88 =@status sX0 Kb0 6glS@statusrc0K0 Y0&glS88 Y@pre_creation_commandd t0Ka0:6glS:@pre_creation_commandNO0K0M0&glSM@resolver_clsidscrh0Kc0.6glS.@resolver_clsid 0K0G0&glS  G@insert_procn`0K`0(6glS (@insert_proc0K0G0&glS  G@update_procb`0Kf0(6glS (@update_proc0K0G0&glS  G@select_proc `0Ke0(6glS (@select_proc0K0U0&glS  U@destination_objecttiop0K`066glS 6@destination_objectpu0K0K0&glS88  K@missing_counted0Kb0,6glS ,@missing_count0K0I0&glS I@missing_cols @dd0Kb0*6glS*@missing_cols 0K0Q0&glSQ@article_resolver= @l0K^026glS2@articleresolver 0 K0K0&glSK@resolver_info d0!Ki0 ,6glS,@resolver_info0"K0!K0&glSK@filter_clausedd0#Kb0",6glS,@filter_clauseP0$K 0glS8bmign 0%KglS0&KPT0^0*glSP "7 ^sp_MSaddinitialarticle> t0'K!20:6glS:sp_MSaddinitialarticleerD0(K[d0 glS 0)K+ 0glS -- Called at he subscriber CREATE PROCEDURE sp_MSaddinitialarticle( @article sysname, /* Name of the article */ @artid uniqueidentifier, /* Article ID */ @pubid uniqueidentifier, /* Publication ID */ @nickname int, /* Article nickname */ @column_tracking int, /* Does the article have column tracking ? */ @status int, /* Status of the article */ @pre_creation_command int = 0, /* Precreate command of the article */ @resolver_clsid nvarchar(255) = NULL,/* Resolver odule for the article */ @insert_proc nvarchar(255) = NULL,/* Insert sp for article */ @update_proc nvarchar(255) = NULL,/* Update sp for article */ @select_proc nvarchar(255) = NULL, /* Select SP for this article */ @destination_object sysname, /* Destination object name */ @missing_count int = NULL, @missing_cols varbinary(32) = NULL, @article_resolver nvarchar(255) = NULL, @resolver_info nvarchar(255) = NULL, @filter_clause nvarchar(2000) = NULL ) AS SETNOCOUNT ON declare @objid int declare @retcode int /* ** Check for subscribing permission */ exec @retcode=sp_MSreplcheck_subscribe if @retcode<>0 or @@ERROR<>0 return (1) if (@artid is NULL) BEGIN RAISERROR (14057, 16, -1) RETURN (1) END if (@resolver_clsid='') select @resolver_clsid = NULL if (@filter_clause='') set @filter_clause = NULL /* ** Populate the local copy of sysmergearticles */ if exists (select * from sysmergearticles where artid = @atid and pubid = @pubid ) begin update sysmergearticles set name = @article, artid = @artid, pre_creation_command = pre_creation_command, pubid = @pubid, nickname = @nickname, column_tracking = @column_tracking, status = @status, resolver_clsid = @resolver_clsid, insert_proc = @insert_proc, update_proc = @update_proc, select_proc = @select_proc, destination_object = @destination_object, missing_col_count = @missing_count, missing_cols = @missing_cols, article_resolver = @article_resolver, resolver_info = @resolver_info, subset_filterclause = @filter_clause where artid = @artid and pubid = @pubid end else begin select @objid = 0 insert sysmergearticles (name, objid, sync_objid, artid, pre_creation_command, pubid, nickname, column_tracking, status, resolver_clsid, insert_proc, update_proc, select_proc, destination_object, missing_col_count, missing_cols, article_reolver, resolver_info, subset_filterclause) values (@article, @objid, @objid, @artid, @pre_creation_command, @pubid, @nickname, @column_tracking, @status, @resolver_clsid, @insert_proc, @update_proc, @select_proc, @destination_object, @missing_count, @missing_cols, @article_resolver, @resolver_info, @filter_clause) end IF @@ERROR <> 0 BEGIN RAISERROR (14057, 16, -1) RETURN (1) END RETURN 0 P0* K 0P0+ K0+P0, K0, P0- K0-40K"70́CV0``T4  4 L L l ,DH\|T4\ raiserror (20001, 11, -1, @article, @publicats r mt_  0DPT0'TLd"7 user_transaction 0LglSt0LPT0 **glS ^`40Ld"70(@f0D\ /';0&b );@pname T/'00@M"7 grrevL0M\v 0glS P0 M 0. 40M"70dV0m0X.L/ *<H.L/ .*S ro (*0D c0(ATٴUhNE#74sp_MSaddinitialpublication|0N$0#C0&TC@publishera\0Nx0$$6T$@publisher0N%0I0&TI@publisher_dbond0Ny0*6T*@publisher_db 0N&0G0&TG@publication `0Nx0(6T(@publication0N'0G0&TG@description `0 Nx0(6T(@descriptiont0 N(0 ;0&T$$;@pubidHT0 Ny0 6T@pubid|0 N)0 C0&T88 C@retention5\0 N}0 $6T$@retention|0N*0 C0&T88 C@sync_moden\0N~0$6T$@sync_mode0N+0E0&T88 E@allow_push91`0Nx0&6T&@allow_pushL0N,0E0&T88  E@allow_pullBC`0Nx0&6T &@allow_pulls0N-0O0&T88  O@allow_anonymous'h0Nx006T 0@allow_anonymous0N.0[0&T88  [@centralized_conflicts t0N{0<6T <@centralized_conflictsx0N/0=0&T88  =@status (X0N06T @statusf0N00M0&T88  M@snapshot_readycrh0N0.6T .@snapshot_readyr0N10Y0&T88 Y@enabled_for_internetalt0N}0:6T:@enabled_for_internett0N20Q0&T88 Q@publication_type fl0N02T2@publication_type_P0 N 0%T8bmTE 0!NT0"N+f0*TP E#7 fsp_MSaddinitialpublicationt|0#N!30(B6TBsp_MSaddinitialpublicationlD0$N[k0) HO/E#7SplitNextD0& O07/sd@atL0'ONL0(ON+n L0)O+N-p(LD4 < 4 D t l  |<` Dd @\lx8L/  )T6 8)*0,0*O0(0ʚ Ucreate procedure sp_MSscript_insert_statement @objid int, @columns binary(32) as declare @cmd nvarchar(4000) declare @cmd2 nvarchar(4000) declare @qualname nvarchar(512) declare @colname sysname declare @typestring nvarchar(4000) declare @spacer nvarchar(1) declare @ccoltype sysname declare @src_cols int declare @this_col int declare @art_col int declare @rc int declare @num_col int select @src_cols = count(*) from syscolumns where id = @objid exec sp_MSget_qualified_name @objid, @qualname OUTPUT select @cmd2 = N'insert into ' + @qualname + N'( ' -- col names select @spacer = N' ' select @this_col = 1 select @art_col = 1 select @cmd = N'' select @num_col = 0 while @this_col <= @src_cols begin exec @rc = dbo.sp_MSget_colinfo @objid, @this_col, @columns, 0, @colname output, @ccoltype output if @rc = 0 and EXISTS (select name from syscolumns where id=@objid and colid=@this_col and iscomputed<>1) begin if rtrim(@ccoltype) not like N'timestamp' and ColumnProperty(@objid, @colname, 'IsIdentity') != 1 begin select @num_col = @num_col + 1 if @cmd2 is not null begin exec dbo.sp_MSflush_command @cmd2 output, 1 select @cmd2 = null end select @cmd = @cmd + @spacer + QUOTENAME(@colname) select @spacer = N',' exec dbo.sp_MSflush_command @cmd output, 0 end end select @this_col = @this_col + 1 end if @num_col > 0 begin -- save off cmd fragment exec dbo.sp_MSflush_command @cmd output, 1 insert into #proctext(procedure_text) values( N') values (') -- col values select @spacer = N' ' select @this_col = 1 select @art_col = 1 select @cmd = N'' while @this_col <= @src_cols begin exec @rc = dbo.sp_MSget_colinfo @objid, @this_col, @columns, 0, @colname output, @ccoltype output if @rc = 0 and EXISTS (select name from syscolumns where id=@objid and colid=@this_col and iscomputed<>1) begin if rtrim(@ccoltype) not like N'timestamp' and ColumnProperty(@objid, @colname, 'IsIdentity') != 1 begin select @cmd = @cmd + @spacer + N'@c' + convert(varchar(4), @this_col) select @spacer = N',' end end exec dbo.sp_MSflush_command @cmd output, 0 select @this_col = @this_col + 1 end -- save off cmd fragment exec dbo.sp_MSflush_command @cmd output, 1 insert into #proctext(procedure_text) values( N') ') end else -- set the @@rowcount insert into #proctext(procedure_text) values( N' select @retcode = @retcode ') D<0 ON0)x8L0O)A0;ʚ UP0 O 040&OE#70&V00%NN00T 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 ? */ @centralizd_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 */ ) AS SET NOCOUNT ON declare @retcode int /* ** NOTE -- WORKAROUND ODBC BUG WHICH have not been reproed. */ select @publication = RTRIM(@publication) slect @publisher_db = RTRIM(@publisher_db) /* ** Check for subscribing permission */ exec @retcode=sp_MSreplcheck_subscribe if @retcode<>0 or @@ERROR<>0 return (1) /* ** Populate the local copy of sysmergepublications */ BEGIN TRAN save TRAN MSaddinitialpublication if exists (select * from sysmergepublications where name = @publication and UPPER(publisher)=UPPER(@publisher) and publisher_db=@publisher_db) begin declare @pubid_local uniqueidentifier select @pubi_local = pubid from sysmergepublications where name = @publication and UPPER(publisher)=UPPER(@publisher) and publisher_db=@publisher_db 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 I @@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 = @publication, description = @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 where name = @publication and UPPER(publisher) = UPPER(@publisher) and publisher_db = @publisher_db end else begin insert sysmergepblications(publisher, publisher_db,pubid, name, description, designmasterid, retention, parentid, sync_mode, allow_push, allow_pull, allow_anonymous, centralized_conflicts, status, snapshot_ready, enabled_for_internet, publication_type) 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_internet, @publication_type) 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(l0NN030T3 RETURN (1) tP0 N 0P N0P0 N0 P0 N0 40NJ#70 ((L(''@'PD if @action is null OR @action not in ('create','drop','start_full','start_incremental','stop','rebuild') OR @ftcat is null OR len(@ftcat) = 0 OR (@path is not null and @0 u Fdee *0D0#/TP#7 user_transaction 0PTt0P0 **T(mut b fwh if40P#70(@f0D\00,-1,-1) return 1 end -- CATALOG MUST EXIST IF NOT CREATING -- declare @ftcatid smallint select @ftcat00@Q#7 grrev@fL0Q\y 0T P0 Q 0 40Q#70dV00Xtcat) return 1 end -- GET CATID AND INSERT ROW -- begin tran if not exists (select * from sysfulltextcatalogs where ftcatid = 5) select @ftcatid = 5 else select @ftcatid = min(ft:Z\0D c0(AٴUVlRv$76sp_MSaddinitialsubscriptionLOt0RT0;0&ٴU$$;@pubidrT0R+6ٴU@pubidt0RU0;0&ٴU$$;@subid=T0R06ٴU@subid|0RV0C0&ٴU$$C@partneride\0R0$6ٴU$@partnerid0RW0E0&ٴUE@subscriber' `0 R0&6ٴU&@subcriber 0 RX0 K0&ٴUK@subscriber_db d0 R0 ,6ٴU,@subscriber_db0 RY0 W0&ٴU;;W@subscriber_priority,p0 R0 86ٴU8@subscriber_priority0RZ0 O0&ٴU00O@subscriber_type'h0R006ٴU0@subscriber_type0R[0S0&ٴU88 S@subscription_type l0R046ٴU4@subscription_typeHS/v$7SplitNext80S0V0L0 S0'/D0 S0/@80 S'hx8L0S&L0S0 iL0S+an0S05EEIOQKGEAA_[QISYWSQOKKIEE;?=EC;;CEKWOSIGCIGCE;A7EG9KE0&9UECOLUMN_NAMEic0&9U$$ECOLUMN_GUIDe,0&9U88 ICOLUMN_PROPIDb 0&9U88 OORDINAL_POSITION 0&9UhhQCOLUMN_HASDEFAULT p0&9U KCOLUMN_DEFAULTt0&9U88  GCOLUMN_FLAGS 0&9Uhh  EIS_NULLABLEyp0&9U44 ! ADATA_TYPEcr0&9U$$ # ATYPE_GUID@d0&9U88 3_CHARACTER_MAXIMUM_LENGTHn0&9U88 7[CHARACTER_OCTET_LENGTH 0&9U44;QNUMERIC_PRECISION i0&9U44=INUMERIC_SCALEnc0&9U88 ?SDATETIME_PRECISIONc0&9UYCHARACTER_SET_CATALOG 0&9UWCHARACTER_SET_SCHEMAr0&9USCHARACTER_SET_NAME 0&9UQCOLLATION_CATALOGla0&9UOCOLLATION_SCHEMAe0&9UKCOLLATION_NAMEn0&9UKDOMAIN_CATALOGc0&9UIDOMAIN_SCHEMAet0&9UEDOMAIN_NAME 0&9U@EDESCRIPTIONic0&ʚ U88 ;@objid 0&ʚ U ?@columns 0&c5U=@dbname s0&c5UE@skipchecks U0&U88 C@validsubsr0&ٴU$$;@pubidU0&ٴU$$;@subidt0&ٴU$$C@partnerids0&ٴUE@subscriberR 0&ٴUK@subscriber_db 0&ٴU;;W@subscriber_priority 0&ٴU00O@subscriber_typee0&ٴU88 S@subscription_type 0&rUITABLE_CATALOGUP0&rUGTABLE_SCHEMAr0&rUCTABLE_NAMEp0&rUIINDEX_CATALOG c0&rUGINDEX_SCHEMA 0&rUCINDEX_NAMEg0&rUhhEPRIMARY_KEYd 0&rUhh;UNIQUEn0&rUhh  ACLUSTEREDns0&rU44  7TYPEb0&rU88  EFILL_FACTORas0&rU88 GINITIAL_SIZE 0&rU88  9NULLS 0&rUhhKSORT_BOOKMARKS 0&rUhhEAUTO_UPDATE <0 S605x8L0S/9UrP0 S040Sv$70V05|0R&0C0&ٴU00  C@sync_type \0 R0$6ٴU $@sync_typeP0!R 0!ٴU˧i P0"R 0"ٴU(biP0#R 0#ٴU( P0$R 0$ٴU!Jo b 0%RٴU40&R 0h0*ٴUP v$7 hsp_MSaddinitialsubscription|0'R40$D6ٴUDsp_MSaddinitialsubscriptionD0(R[r0% ٴUHT/v$7SplitNextD0* T0/d @anL0+TOL0,TO+#OyL0-T+Or 0.T0,0Vcreate procedure sp_MSscript_update_statement @publication sysname, @article sysname, @objid int, @columns binary(32) as declare @cmd nvarchar(4000) declare @cmd2 nvarchar(4000) declare @qualname nvarchar(512) declare @colname sysname declare @typestring nvarchar(4000) declare @spacer nvarchar(1) declare @ccoltype sysname declare @src_cols int declare @this_col int declare @rc int declare @column nvarchar(100) declare @num_col int select @src_cols = count(*) from syscolumns where id = @objid exec sp_MSget_qualified_name @objid, @qualname OUTPUT select @cmd2 = N'update ' + @qualname + N' set' -- col names select @spacer = N' ' select @this_col = 1 select @cmd = N'' -- If the table have only identity in pk and a ts col, update statement will be empty -- and the query will fail. Prevent it here. select @num_col = 0 -- script update while @this_col <= @src_cols begin exec @rc = dbo.sp_MSget_colinfo @objid, @this_col, @columns, 0, @colname output, @ccoltype output if @rc = 0 and EXISTS (select name from syscolumns where id=@objid and colid=@this_col and iscomputed<>1) begin if rtrim(@ccoltype) not like N'timestamp' and ColumnProperty(@objid, @colname, 'IsIdentity') != 1 begin if @cmd2 is not null begin exec dbo.sp_MSflush_command @cmd2 output, 1 select @cmd2 = null end select @num_col = @num_col + 1 -- Optimization: -- Get null or actual column name -- Note: the output is quoted. exec dbo.sp_MSget_synctran_column @ts_col = null, @op_type = null , -- 'ins, 'upd', 'del' @is_new = null, @primary_key_bitmap = null, @colname = @colname, @this_col = @this_col, @column = @column output, @from_proc = 1 select @cmd = @cmd + @spacer + QUOTENAME(@colname) + N' = ' + @column select @spacer = N',' -- flush command if necessary exec dbo.sp_MSflush_command @cmd output, 0 end end select @this_col = @this_col + 1 end -- save off cmd fragment if @num_col > 0 begin exec dbo.sp_MSflush_command @cmd output, 1 -- Determine method of conflict detection and add where clause if ObjectProperty(@objid, 'TableHasTimestamp') = 1 begin exec @rc = dbo.sp_MSis_col_replicated @publication, @article, 'timestamp', @colname OUTPUT if @rc = 1 begin insert into #proctext(procedure_text) values( N' ') exec dbo.sp_MSscript_where_clause @objid, @columns, 'upd ts', @colname, 4 end end else begin insert into #proctext(procedure_text) values( N' ') exec dbo.sp_MSscript_where_clause @objid, @columns, 'upd rc', null, 4 end end else -- set the @@rowcount insert into #proctext(procedure_text) values( N' select @retcode = @retcode ') sp<0/ TO0-x8L00T)D0VpaP01 T 040*Tv$70*V00)RO000ٴU CREATE PROCEDURE sp_MSaddinitialsubscription( @pubid uniqueidentifier, /* Publication ID */ @subid uniqueidentifier, /* Subscription's eplica ID */ @partnerid uniqueidentifier, /* Partner's replica ID */ @subscriber sysname, /* Subscriber server */ @subscriber_db sysname, /* Subscriber database */ @subscriber_priority real = 0.0, /* Subscriber priority */ @subscriber_type tinyint = 0, /* Subscriber type - local, global, or anonymous */ @subscription_type int = 0, /* Subscription type - push or pull */ @sync_type tinyint = 2 /* Subscription sync type 1 = no sync, 2 = automatic */ ) AS SET NOCOUNT ON /* ** Declarations. */ DECLARE @local tinyint DECLARE @anonymous tinyint DECLARE @subscriber_srvid int DECLARE @subnickname int DECLARE @active tinyint DECLARE @retcode int DECLARE @subid_old uniqueidentifier /* ** Initializations */ SET @local = 2 SET @anonymous = 3 set @active = 1 /* after this SP is called, the subscription is activated */ select @subscriber_db = RTRIM(@ubscriber_db) /* ** Check for subscribing permission ** It is called by merge agent at the publisher side ** subscriber side? */ -- @pubid is not local exec @retcode= dbo.sp_MSreplcheck_connection @pubid = @pubid if @retcode<>0 or @@ERROR<>0 return (1) -- this gets executed at both publisher (for pull subscriptions) and at subscriber -- if server is not found use srvid of 0 for local srvid select @subscriber_srvid = srvid from master..sysservers where srvname = @subscriber f @subscriber_srvid is null set @subscriber_srvid = 0 begin tran save TRAN MSaddinitialsubscription /* ** Populate the local copy of sysmergesubscriptions */ if exists (select * from sysmergesubscriptions where subid = @subid) begin update sysmergesubscriptions SET subid = @subid, datasource_type = 0, datasource_path = NULL, srvid = @subscriber_srvid, db_name = @subscriber_db, pubid = @pubid, status = @active, subscriber_type = @subscriber_type, subscription_type = @subscription_type, priority = @subscriber_priority, sync_type = @sync_type where subid = @subid IF @@ERROR <> 0 BEGIN goto FAILURE END end if exists (select * from sysmergesubscriptions where srvid = @subscriber_srvid AND db_name = @subscriber_db AND pubid = @pubid) begin select @subid_old = subid from sysmergesubscriptions where rvid = @subscriber_srvid AND db_name = @subscriber_db AND pubid = @pubid update sysmergesubscriptions SET subid = @subid, datasource_type = 0, datasource_path = NULL, srvid = @subscriber_srvid, db_name = @subscriber_db, pubid = @pubid, status = @active, subscriber_type = @subscriber_type, subscription_type = @subscription_type, priority = @subscriber_priority, sync_type = @sync_type where srvid =@subscriber_srvid AND db_name = @subscriber_db AND pubid = @pubid IF @@ERROR <> 0 BEGIN goto FAILURE END if (@subid_old IS NOT NULL) begin /* ** Delete old row for subscriber from MSmerge_replinfo. */ DELETE from MSmerge_replinfo where repid = @subid_old IF @@ERROR <> 0 BEGIN goto FAILURE END EXECUTE @retcode = dbo.sp_MSgenreplnickname @subid,@subnickname output if @@ERROR<>0 or @retcode<>0 goto FAILURE /* ** Add new row for subscriber to MSmerge_replinfo. */ INSERT INTO MSmerge_replinfo(repid, replnickname) values (@subid, @su04RO040ٴUbnickname) IF @@ERROR <> 0 BEGIN goto FAILURE END end end else begin INSERT sysmergesubscriptions(subid, partnerid, datasource_type, datasource_path, srvid, db_name, pubid, status, subscriber_type, subscription_type, priority, sync_type, description, login_name) VALUES (@subid, @partnerid, 0, NULL, @subscriber_srvid, @subscriber_db, @pubid, @active, @subscriber_type, @subscription_type, @subscriber_priority, @sync_type, NULL, suser_sname(suser_sid())) IF @@ERROR <> 0 BEGIN goto FAILURE END /* Look for existing nickname from any other subscription */ select @subnickname = max(replnickname) from MSmerge_replinfo, sysmergesubscriptions where repid = subid and srvid = @subscriber_srvid and db_name = @subscriber_db /* Generate a new replica nickname from the @subid */ if (@subnickname is null) begin EXECUTE @retcode = dbo.sp_MSgenreplnickname @subid, @subnickname output if @@ERROR<>0 or @retcode<>0 goto FAILURE end /* ** Add row for subscriber to MSmerge_replinfo. */ INSERT INTO MSmerge_replinfo(repid, replnickname) values (@subid, @subnickname) IF @@ERROR <> 0 BEGIN goto FAILURE END end COMMIT TRAN RETURN 0 FAILURE: /* UNDONE : This code is specific to 6.X nested transaction semantics */ if @@TRANCOUNT > 0 begin ROLLBACK TRANSACTION MSaddinitialsubscription COMMIT TRANSACTION end RAISERROR (14057, 16, -1) RETURN 1 P05 R 02P06 R06P07 R07 P08 R0 40Rv$70 $ZYY4YXI988H8 8 4dH(8@ t ( `(t0X<\/f /C0&GC@tablename\/t/$6G$@tablename|/f /8 s is r!s\0AD 0'x8TU$7 user_transaction 0AUٴUt0AU 0A **ٴU" hjo40AU$70A(@f0D\G0&G88 G@basetableid`/ t/00B@V%7 grrevL0BV\| 0ٴU P0B V 09 40BV%70BdV0l0X / GT1P/ /GP/ /!R0CD c0(AVKW`W%7*sp_MSmakearticleprocst0CW0;0&V$$;@pubidT0CW90!6V@pubidt0CW0C;0&V$$;@artidT0W90C6V@artidP0CW 0%V8bm*P0CW 0CVtP0CW 0CVP0C W 0C VP0C W 0C VP0C W C VNP0C W 0C V5I 0C WV40CW0A\0*VP %7 \sp_MSmakearticleprocsp0CW"0p 86V8sp_MSmakearticleprocsD0CW[y0) VHX/%7SplitNextD0C X0+/@ L0CXL0CX0.L0CX%sS0CX0C)?0ݳV)xpstar.dllne0<W?create procedure sp_MSscript_delete_statement @publication sysname, @article sysname, @objid int, @columns binary(32) as declare @cmd nvarchar(4000) declare @qualname nvarchar(512) declare @colname sysname declare @typestring nvarchar(4000) declare @spacer nvarchar(1) declare @ccoltype sysname declare @src_cols int declare @this_col int declare @art_col int declare @rc int select @src_cols = count(*) from syscolumns whee id = @objid exec sp_MSget_qualified_name @objid, @qualname OUTPUT select @cmd = N'delete ' + @qualname exec dbo.sp_MSflush_command @cmd output, 1 -- Determine method of conflict detection and add where clause insert into #proctext(procedure_text) values( N' ') if ObjectProperty(@objid, 'TableHasTimestamp') = 1 begin exec @rc = dbo.sp_MSis_col_replicated @publication, @article, 'timestamp', @colname OUTPUT if @rc = 1 exec dbo.sp_MSscriptwhere_clause @objid, @columns, 'upd ts', @colname, 4 else exec dbo.sp_MSscript_where_clause @objid, @columns, 'upd rc', null, 4 end else exec dbo.sp_MSscript_where_clause @objid, @columns, 'upd rc', null, 4 o<0C X0Cpx8L0CX)F01ݳV=P0C X 0B40CX%70CV0 0CW0C[ 0V[ create procedure sp_MSmakearticleprocs (@pubid uniqueidentifier, @artid uniqueidentifier) as declare @ownername sysname declare @objectname sysname declare @ins_procname sysname declare @sel_procname sysname declare @upd_procname sysname declare @guidstr nvarchar(40) declare @ext nvarchar(10) declare @trigname sysname declare @objid int declare @dbname sysname declare @command nvarchar(100) -- to be called after article is set up in a subscriber declare @retcode smallint /* ** Check for subscribing permission */ exec @retcode=sp_MSreplcheck_subscribe if @retcode<>0 or @@ERROR<>0 return (1) select @objid = max(objid) from sysmergearticles where artid = @artid -- get owner name, and table name select @objectname = name, @ownername = user_name(uid) from sysobjects where id = @objid -- get the insert and update proc names from sys articles select @ins_procnae = insert_proc, @upd_procname = update_proc, @sel_procname = select_proc from sysmergearticles where pubid = @pubid and artid = @artid -- create the procs set @dbname = db_name() /* If procedure already exists because article in multiple pubs don't bother */ if not exists (select * from sysobjects where name = @ins_procname and type = 'P') begin set @command = 'sp_MSmakeinsertproc ' + QUOTENAME(@objectname) + ' , ' + QUOTENAME(@ownername) + ' , ' + @ins_procname + ', [' + convert(nchar36), @pubid) + ']' exec @retcode = master..xp_execresultset @command, @dbname if @@ERROR<>0 OR @retcode <>0 return (1) exec @retcode = dbo.sp_MS_marksystemobject @ins_procname if @@ERROR<>0 return (1) end exec ('grant exec on ' + @ins_procname + ' to public') if @@ERROR<>0 return (1) /* If procedure already exists because article in multiple pubs don't bother */ if not exists (select * from sysobjects where name = @upd_procname and type = 'P') begin set @command = 'sp_MSmkeupdateproc ' + QUOTENAME(@objectname) + ' , ' + QUOTENAME(@ownername) + ' , ' + @upd_procname exec @retcode = master..xp_execresultset @command, @dbname if @@ERROR<>0 OR @retcode <>0 return (1) exec @retcode = dbo.sp_MS_marksystemobject @upd_procname if @@ERROR<>0 return (1) exec ('grant exec on ' + @upd_procname + ' to public') if @@ERROR<>0 return (1) end /* If procedure already exists because article in multiple pubs don't bother */ if not exists (select * from sysobject where name = @sel_procname and type = 'P') begin set @command = 'sp_MSmakeselectproc ' + QUOTENAME(@objectname) + ' , ' + QUOTENAME(@ownername) + ' , ' + @sel_procname exec (@command) if @@ERROR<>0 return (1) exec @retcode = dbo.sp_MS_marksystemobject @sel_procname if @@ERROR<>0 return (1) exec ('grant exec on ' + @sel_procname + ' to public') if @@ERROR<>0 return (1) end =P0C W 0CP0C W0CP0C W0C P0C W0C40CW%70ĆCV0< 8 Tp,0|,<L0\ow create the procedure select @procname = QUOTENAME(@procname) execute ('Creasa(m0_r 0C0QD0Cx8TY%7 user_transaction 0QYVt0QY0Q **Vo ' \q^am40QY%70Q(@f0D\ (' + @vallist + ')') IF @@ERROR <> 0 begin return(1) 00R@Z3&7 grreveL0RZ\ 0BV P0R Z 0C 40RZ3&70RdV00X/' /'P/( /( P/) /)0SD c0C(AKW!Xl[&76sp_MSupdatesysmergearticlesx0S[0C=0&KW=@object$$X0S[E0C6KW@object t0S[0S;0&KW$$;@artid(T0S[E0S6KW@artidt0S[0S;0&KW;@ownerT0S[G0S6KW@ownerP0S[ 0C KWf0P0S [ 0S KWoiP0S [  0S KWP0S [  0S KW8bmP0S [  0S KWSM(pP0S [  0S KWT0S[  0S KWT0S[  0S| KW 0S[KW40S[0Qh0*KWP &7 hsp_MSupdatesysmergearticles|0S[]70D6KWDsp_MSupdatesysmergearticlesD0S[[0C KW0S[P+#o0KWo CREATE PROCEDURE sp_MSupdatesysmergearticles( @object sysname, /* Name of the table */ @artid uniqueidentifier, /* Article ID */ @owner sysname = NULL ) AS declare @merge_pub_object_bit int declare @id int declare @qualified_name nvarchar(268) SET NOCOUNT ON declare @retcode int if @owner is NULL or @owner = '' begin if exists (select name from sysobjects where id = object_id(@object)) select @owner = user_name(uid) from sysobjects where id = object_id(QUOTENAME(@object)) else begin raiserror(21078, 16, -1, @object) return (1) end end select @qualified_name = QUOTENAME(@owner) + '.' + QUOTENAME(@object) /* ** Check to see if current publication has permission */ /* ** Check for subscribing permission */ exec @retcode=sp_MSreplcheck_subscribe if @retcode<>0 or @@ERROR<>0 return (1) select @merge_pub_object_bit = 128 if (@artid is NULL) BEGIN RAISERROR (14057, 16, -1) RETURN (1) END begin tran if exists (select name from sysobjects where id = object_id(@qualified_name)) begin exec dbo.sp_replupdateschema @qualified_name update sysobjects set replinfo = replinfo | @merge_pub_object_bit where id=object_id(@qualified_name) if @@ERROR<>0 goto UNDO /* ** update the local copy of sysmergearticles */ update sysmergearticles set objid = OBJECT_ID(@qualified_name) where artid = @artid IF @@ERROR <> 0 BEGIN RAISERROR (14057, 16, -1) goto UNDO END end else -- THIS IS FINE. This dynimic query is there to provide a good error message. No need to use SP. raiserror(21078, 16, -1, @object) commit tran RETURN 0 UNDO: if @@TRANCOUNT = 1 ROLLBACK TRAN else COMMIT TRAN RETURN 1 mP0S [ 0P0S [0SP0S [0S  P0S [0S40S[&70ŚCV0x(0p\hx(` @\*eH P/ ! /*4/R0_D0ST\'7 user_transaction 0_\KWt0_\0_ **KW a h_j1) 40_\'70_(@f0D\ begin raiserror(15065,-1,-1) return (1) end -- ADD IMPLICIT SYSUSERS ENTRY -- m00`@]_'7 grrev3L0`]\ 0RKW P0` ] 0S 40`]_'70`dV0/0X/Y/6՜3@repidx/G/=0&՜388 =@srcgeneinX/$ 0aD c0S(A!XEY\^'7&sp_MSmakeinsertproc@|0a^<0SC0&!XC@tablename\0a^e0S$6!X$@tablename|0a^=0aC0&!XC@ownername\0a^e0a$6!X$@ownername|0a^>0aA0&!XA@procname\0a^f0a"6!X"@procnamet0a^?0a;0&!X$$;@pubid$T0a ^g0a6!X@pbidP0a ^ +!X8bmHP0a ^ 0a !Xixsp_P0a ^ 0a !X@arP0a ^ 0a !XchaP0a^ 0a!XherP0a^ 0a!X @quP0a^ 0a!Xre P0a^ 0a!XlarP0a^ 0a!XrecP0a^ 0a!X ' P0a^ 0a!X$.} c. 0a^!X40a^ 0_X0*!XP '7 sp_MSmakeinsertprocl0a^"0C46!X4sp_MSmakeinsertprocD0a^[0S !X0a^+ 0!X -- This will be called by snapshot at publisher side and -- merge at the subscriber side, check for dbo permission create procedure sp_MSmakeinsertproc (@tablename sysname, @ownername sysname, @procname sysname,@pubid uniqueidentifier) as declare @argname sysname declare @id int declare @qualified_name nvarchar(255) declare @idstr nvarchar(100) if @ownername is NULL or @ownername='' select @qualified_name = QUOTENAME(@tablename) else select @qualified_name = QUOTENAME(@ownername) + '.' + QUOTENAME(@tablename) select @id = object_id(@qualified_name) if @id is NULL return (1) set @idstr = rtrim(convert(nchar, @id)) declare @retcode smallint declare @colname sysname declare @rgclname sysname declare @typename sysname declare @colid smallint declare @status tinyint declare @len smallint declare @prec smallint declare @scale int declare @tablenick int declare @tablenickstr nvarchar(12) declare @colordinal smallint declare @cmdpiece nvarchar(4000) set nocount on /* ** Check for subscribing permission */ exec @retcode=sp_MSreplcheck_subscribe if @retcode<>0 or @@ERROR<>0 return (1) execute @retcode = dbo.sp_MStablenickname @ownername, @tablename, @tablenik output IF @@ERROR <> 0 or @retcode <>0 return (1) set @tablenickstr = rtrim(convert(nchar, @tablenick)) -- create temp table to select the command text out of create table #tempcmd (phase int NOT NULL, step int identity NOT NULL, cmdtext nvarchar(4000) NULL) -- insert text pieces that don't repeat for each column -- phase 0 : create procedure and fixed part of argument list set @cmdpiece = 'create procedure dbo.' + QUOTENAME(@procname) + ' (@rowguid uniqueidentifier, @generation int, @lieage varbinary(255), @colv varbinary(2048) ' insert into #tempcmd (phase, cmdtext) values (0, @cmdpiece) -- phase 1 is rest of argument list; goes in during loop over columns -- phase 2 : paren to close argument list, and variable declarations set @cmdpiece = ') as declare @tablenick int declare @success int declare @retcode int exec @retcode = dbo.sp_MSreplcheck_connection @objid = ' + @idstr + ' if @retcode<>0 or @@ERROR<>0 return (3) select @tablenick = ' + @tablenickstr + ' st @success = 0 ' insert into #tempcmd (phase, cmdtext) values (2, @cmdpiece) -- phase 3 is optional set identity insert on, goes in during loop if needed -- phase 4 is beginning a sub transaction, setting save point and starting insert statement set @cmdpiece = ' begin transaction sub save transaction sp1 exec dbo.sp_MSsetrowmetadata @tablenick, @rowguid, @generation, @lineage, @colv, 2 insert into ' + @qualified_name + ' (' insert into #tempcmd (phase, cmdtext) values (4, @cmdpiece) --phase 5 is column list that we are inserting; done in loop -- phase 6 is just the opening and closing parens and VALUES keyword set @cmdpiece = ') values (' insert into #tempcmd (phase, cmdtext) values (6, @cmdpiece) -- phase 7 is all of those arguments as the list of value expressions; done in loop -- phase 8 finish insert, check status, etc. -- if we have a permanent view, check for case where we inserted a row that doesn't -- meet filters of subscriber we are getting the insert from set @cmdiece = ') if (@@rowcount = 1) begin set @success = 1 end else begin select @success = 3 end ' insert into #tempcmd (phase, cmdtext) values (8, @cmdpiece) if exists (select * from sysmergearticles where pubid = @pubid and objid = @id and view_type = 1) begin /* Get name of rowguidcol. Aliasing doesn't work through a view. */ select @rgcolname = QUOTENAME(name) from syscolumns where id = @id and ColumnProperty(@id, name, 'isrowguidcol') = 1 if @rgcolname is null set @rgcolname = 'rowguid' select @cmdpiece = ' if not exists (select * from ' + QUOTENAME(OBJECT_NAME(sync_objid)) from sysmergearticles where pubid = @pubid and objid = @id set @cmdpieH_/'7SplitNextD0a _0C/@L0a_L0a_0asSL0a_%x0a_0a>0+X>create procedure sp_MSscript_security @publication sysname as declare @cmd nvarchar(4000) -- insert into #proctext(procedure_text) values(N'declare @retcode int') insert into #proctext(procedure_text) values(N'exec @retcode = dbo.sp_MSreplcheck_pull') insert into #proctext(procedure_text) values(N'@publication = ''' + @publication + ''' ' ) isert into #proctext(procedure_text) values(N'if @retcode <> 0 or @@error <> 0' ) insert into #proctext(procedure_text) values(N' return -1 ') *<0a _0aBx8L0a!_*,%!X_P0a" _ 0`40a_'70aV088T(x(8HX@h 4yar0* ;X 3 Hxp_regwrite0*6@;P Ε2 Psp_serveroption0*`;P Ub6^sp_helparticlecolumnsca0*`u;P 62 dsp_fallback_MS_sel_fb_svr0*ҕ;P -5 dsp_MSregistersubscription0*;X uW5\n p enco Xud 0q 0a^0a  0!X ce = @cmdpiece + ' where ' + @rgcolname + ' = @rowguid) begin update MSmerge_contents set generation = 0, partchangegen = 0 where rowguid = @rowguid and tablenick = @tablenick end ' insert into #tempcmd (phase, cmdtext) values (8, @cmdpiece) end set @cmdpiece = ' if (@success = 3) begin rollback transaction sp1 end commit transaction ' insert into #tempcmd (phas, cmdtext) values (8, @cmdpiece) -- phase 9 is setting identity insert off if needed; done in loop -- phase 10 is returning our success / failure status set @cmdpiece = ' return @success' insert into #tempcmd (phase, cmdtext) values (10, @cmdpiece) -- now loop over columns and insert missing command pieces select @colid = min (colid) from syscolumns where id = @id and iscomputed<>1 select @colname = QUOTENAME(name), @status = status, @typename = type_name(xtype), @len = length, @prec = COLMNPROPERTY(id, name, 'precision'), @scale = scale from syscolumns where id = @id and colid = @colid if @typename='nvarchar' or @typename='nchar' -- a unit of nchar takes 2 bytes select @len = @len/2 set @colordinal = 1 while (@colname is not null) begin exec @retcode = dbo.sp_MSmaptype @typename out, @len, @prec, @scale if @@error<>0 OR @retcode <>0 return (1) select @argname = '@p' + rtrim(convert(nchar, @colordinal)) -- add to argument list (phase 1) set @cmdpiece = ', ' + @argnme + ' ' + @typename insert into #tempcmd (phase, cmdtext) values (1, @cmdpiece) -- add to column list and value list if (@colordinal = 1) begin -- column list is phase 5 set @cmdpiece = @colname insert into #tempcmd (phase, cmdtext) values (5, @cmdpiece) -- argname for values list is phase 7 set @cmdpiece = @argname insert into #tempcmd (phase, cmdtext) values (7, @cmdpiece) end else begin -- column list is phase 5; need preceding comma since not the first one. set @cmdpiece = ', ' + @colname insert into #tempcmd (phase, cmdtext) values (5, @cmdpiece) -- argname for values list is phase 7 need preceding comma since not the first one. set @cmdpiece = ', ' + @argname insert into #tempcmd (phase, cmdtext) values (7, @cmdpiece) end -- is this an identity column? if (@status = 128) begin -- turning identity insert on is phase 3 set @cmdpiece = ' set identity_insert ' + @qualified_name + ' on' insert into #tempcmd (phase, cmdtext) vlues (3, @cmdpiece) -- turning identity insert on is phase 9 set @cmdpiece = ' set identity_insert ' + @qualified_name + ' off' insert into #tempcmd (phase, cmdtext) values (9, @cmdpiece) end -- now set up to repeat the loop with the next column select @colid = min (colid) from syscolumns where id = @id and colid > @colid and iscomputed<>1 set @colname = NULL if @colid is not null select @colname = QUOTENAME(name), @status = status, @typename = type_name(xtype), @len = length, @prec = COLUMNPROPERTY(id, name, 'precision'), @scale = scale from syscolumns where id = @id and colid = @colid if @typename='nvarchar' or @typename='nchar' -- a unit of nchar takes 2 bytes select @len = @len/2 set @colordinal = @colordinal + 1 end -- Now we select out the command text pieces in proper order so that our caller, -- xp_execresultset will execute the command that creates the stored procedure. select cmdtext from #tempcmd order by phase, step P0q ^ 0a#P0q ^0qP0q ^0q P0q ^0q40a^'70ando$4 begin select @UnqualName = PARSENAME(@conflict_table, 1) select a aUe0yD 0a/T`@(7 user_transaction 0y`!Xt0y` 0y **!X var XxZed40y`@(70y(@f0D\ngths select @owner = @QualName1 select @object = @Un00z@a(7 grrevnL0za\ 0`!X P0z a 0q 40za(70zdV0[0Xt_proc , @conflict_proc output if @@ERROR <> 0 OR @retcode <> 0 return(1) exec @retcode=sp_M>NP0{D c0a(AEYiZ\b*)7&sp_MSmakeupdateproc |0{bK0a C0&EYC@tablenamen\0{bt0a $6EY$@tablename|0{bL0{C0&EYC@ownernamer\0{bt0{$6EY$@ownername|0{bM0{A0&EYA@procnamec \0{bu0{"6EY"@procname P0{b" 0aEY8bmP0{ b# 0{ EYixP0{ b"0{ EYP0{ b" 0{ EY P0{ b" 0{ EYeP0{ b$ 0{ EYoP0{b$ 0{EYmP0{b# 0{EYdP0{b# 0{EYP0{b" 0{EYTP0{b, 0{EY$.}n 0{bEY40{b'0yX0*EYP /)7 Xsp_MSmakeupdateprocl0{b"0a46EY4sp_MSmakeupdateprocD0{b[0a EYHc//)7SplitNextD0{ c0a/yI@L0{c#L0{c+#cL0{c#+s 0{c0{ 0OY create procedure sp_MSscript_endproc @objid int, @op_type varchar(3) = 'ins', -- 'ins', 'upd', 'del' @columns binary(32), @outvars nvarchar(4000) as declare @cmd nvarchar(4000) declare @qualname nvarchar(512) exec sp_MSget_qualified_name @objid, @qualname OUTPUT insert into #proctext(procedure_text) values(N' if @@ROWCOUNT = 0 begin exec sp_MSreplraiserror 20515 return -1 end') if @outvars <> null begin insert into #proctext(procedure_text) values(N' else begin ') if @op_type = 'upd' -- Script out pk var assigment that used in sp_MSscript_where_clause exec dbo.sp_MSscript_pkvar_assignment @objid, @columns, 1 insert into #proctext(procedure_text) values(N' ') select @cmd = N' select ' + @outvars insert into #proctext(procedure_text) values( @cmd) select @cmd = N' from ' + @qualname insert into #proctext(procedure_text) values( @cmd) insert into #proctext(procedure_text) values( N' ') if @op_type = 'ins' exec dbo.sp_MSscript_where_clause @objid, @columns, 'new pk', null, 4 else if @op_type = 'upd' exec dbo.sp_MSscript_where_clause @objid, @columns, 'old pk', null, 4 insert into #proctext(procedure_text) values( N' return 0 ') insert into #proctext(procedure_text) values( N'end ') end else begin insert into #proctext(procedure_text) values( N' else return 0') end 16,<0{ c0{ x8L0{c* 0a"EYk P0{ c 0z40{c/)70{V00{b0{0EY -- This will be called by snapshot at publisher side and -- merge at the subscriber side, ceck for dbo permission create procedure sp_MSmakeupdateproc (@tablename sysname, @ownername sysname, @procname sysname) as declare @retcode smallint declare @argname nvarchar(10) declare @varname nvarchar(10) declare @cmdpiece nvarchar(4000) declare @qualified_name nvarchar(255) declare @littlecomp nvarchar(300) declare @id int declare @idstr nvarchar(100) set nocount on if @ownername is NULL or @ownername='' select @qualified_name = QUOTENAME(@tablename) else select @ualified_name = QUOTENAME(@ownername) + '.' + QUOTENAME(@tablename) select @id = object_id(@qualified_name) if @id is NULL return (1) set @idstr = rtrim(convert(nchar, @id)) declare @colname sysname declare @typename sysname declare @colid smallint declare @colordinal smallint declare @colordstr nvarchar(4) declare @status tinyint declare @len smallint declare @blen smallint declare @prec smallint declare @scale int declare @tablenick int declare @tablenickstr nvarchar(12) /* ** Check for dbo permission */ exec @retcode=sp_MSreplcheck_subscribe if @retcode<>0 or @@ERROR<>0 return (1) execute @retcode = dbo.sp_MStablenickname @ownername, @tablename, @tablenick output if @@ERROR <>0 OR @retcode <>0 return (1) set @tablenickstr = rtrim(convert(nchar, @tablenick)) -- create temp table to select the command text out of create table #tempcmd (phase int NOT NULL, step int identity NOT NULL, cmdtext nvarchar(4000) NULL) -- insert text pieces that don't repeat for eah column -- phase 0 : create procedure and fixed part of argument list set @cmdpiece = 'Create procedure dbo.' + @procname + ' (@rowguid uniqueidentifier, @setbm varbinary(125) = NULL, @metadata_type tinyint, @lineage_old varbinary(255), @generation int, @lineage_new varbinary(255), @colv varbinary(2048) ' insert into #tempcmd (phase, cmdtext) values (0, @cmdpiece) -- phase 1 is rest of argument list; goes in during loop over columns -- phase 2 paren to close argument list and fixed variable dclarations set @cmdpiece = ') as declare @tablenick int declare @failure int declare @success int declare @fset int declare @match int declare @retcode smallint exec @retcode = dbo.sp_MSreplcheck_connection @objid = ' + @idstr + ' if @retcode<>0 or @@ERROR<>0 return (3) select @tablenick = ' + @tablenickstr + ' set @failure = 0 ' insert into #tempcmd (phase, cmdtext) values (2, @cmdpiece) -- phase 3 is rest of variable declarations; goes in during loop over columns -- phas 4 begin a transaction, set savepoint in case we roll back, begin select to get current values set @cmdpiece = 'begin transaction sub save transaction sp1 select @success = 2' insert into #tempcmd (phase, cmdtext) values (4, @cmdpiece) -- phase 5 is middle part of select assigning column values to local variables -- goes in loop -- phase 6 -- finish the select, check that metadata matches set @cmdpiece = ' from ' + @qualified_name + ' (updlock) where rowguidcol = @rowguid set @match = @@rowcout exec dbo.sp_MScheckmetadatamatch @metadata_type, @rowguid, @tablenick, @lineage_old, @match output if (@match = 1) begin select @success = 1 ' insert into #tempcmd (phase, cmdtext) values (6, @cmdpiece) -- phase 7 is a bunch of if's that compare old values with new values ; goes in during loop -- phase 8 finish the stored procedure set @cmdpiece = ' if (@failure = 0) exec dbo.sp_MSsetrowmetadata @tablenick, @rowguid, @generation, @lineage_new, @colv, 2 end if (@failure = 1) egin rollback transaction sp1 select @success = 3 end commit transaction return @success' insert into #tempcmd (phase, cmdtext) values (8, @cmdpiece) -- now do the loop over all columns and insert the missing pieces -- don't script out computed columns select @colid = min (colid) from syscolumns whHd//)7SplitNext80{#d0V0L0{$ d0{/D0{% d0{%/@80{& d0!x8L0{'d0#L0{(d0{"#*&bL0{)d#0{ 0{*d0{( 0OY create procedure sp_MSscript_endproc @objid int, @op_type varchar(3) = 'ins', -- 'ins', 'upd', 'del' @columns binary(32), @outvars nvarchar(4000) as declare @cmd nvarchar(4000) declare @qualname nvarchar(512) exec sp_MSget_qualified_name @objid, @qualname OUTPUT insert into #proctext(procedure_text) values(N' if @@ROWCOUNT = 0 begin exec sp_MSreplraiserror 20515 return -1 end') if @outvars <> null begin insert into #proctext(procedure_text) values(N' else begin ') if @op_type = 'upd' -- Script out pk var assigment that used in sp_MSscript_where_clause exec dbo.sp_MSscript_pkvar_assignment @objid, @columns, 1 insert into #proctext(procedure_text) values(N' ') select @cmd = N' select ' + @outvars insert into #proctext(procedure_text) values( @cmd) select @cmd = N' from ' + @qualname insert into #proctext(procedure_text) values( @cmd) insert into #proctext(procedure_text) values( N' ') if @op_type = 'ins' exec dbo.sp_MSscript_where_clause @objid, @columns, 'new pk', null, 4 else if @op_type = 'upd' exec dbo.sp_MSscript_where_clause @objid, @columns, 'old pk', null, 4 insert into #proctext(procedure_text) values( N' return 0 ') insert into #proctext(procedure_text) values( N'end ') end else begin insert into #proctext(procedure_text) values( N' else return 0') end /<0{+ d0{) x8L0{,d* 0{OYP0{- d 0{ 40{#d/)70{#V00{"b0{,0EYere id = @id and iscomputed <> 1 select @colname = QUOTENAME(name), @status = status, @typename = type_name(xtpe), @blen = length, @prec = COLUMNPROPERTY(id, name, 'precision'), @scale = scale from syscolumns where id = @id and colid = @colid if @typename='nvarchar' or @typename='nchar' -- a unit of nchar takes 2 bytes set @len = @blen/2 else set @len = @blen set @colordinal = 1 while (@colname is not null) begin if (@status = 128) begin -- just skip past identity columns as they can't be updated select @colid = min (colid) from syscolumns where id = @id and colid > @colid and iscompued<>1 set @colname = NULL select @colname = QUOTENAME(name), @status = status, @typename = type_name(xtype), @blen = length, @prec = COLUMNPROPERTY(id, name, 'precision'), @scale = scale from syscolumns where id = @id and colid = @colid if @typename='nvarchar' or @typename='nchar' -- a unit of nchar takes 2 bytes set @len = @blen/2 else set @len = @blen set @colordinal = @colordinal + 1 end set @colordstr = convert(nvarchar(4), @colordinal) exec @retcode = dbo.sp_Smaptype @typename out, @len, @prec, @scale if @@ERROR <>0 OR @retcode <>0 return (1) -- put in argument list element (phase 1) set @argname = '@p' + rtrim(@colordstr) set @cmdpiece = ', ' + @argname + ' ' + @typename + ' = NULL ' insert into #tempcmd (phase, cmdtext) values (1, @cmdpiece) -- put in declaration for variable (phase 3) -- text and image get no variable if (@typename <> 'ntext' and @typename <> 'text' and @typename <> 'image') begin set @varname = '@l' + rtrim(@colodstr) set @cmdpiece = 'declare ' + @varname + ' ' + @typename + ' ' insert into #tempcmd (phase, cmdtext) values (3, @cmdpiece) -- put in set piece to initialize variable to old value in select statement (phase 5) set @cmdpiece = ', ' + @varname + ' = ' + @colname insert into #tempcmd (phase, cmdtext) values (5, @cmdpiece) -- put in if piece that compares old value with new, checks bit if argument is null if (@typename like '%char%') begin -- Compare binaries instead of ariables so that case changes are caught as different set @littlecomp = 'convert(varbinary(' + rtrim(convert(nchar, @blen)) + '), ' + @argname + ') = convert(varbinary(' + rtrim(convert(nchar, @blen)) + '), ' + @varname + ')' end else begin set @littlecomp = @argname + ' = ' + @varname end set @cmdpiece = ' if ' + @littlecomp + ' set @fset = 0 else if ' + @argname + ' is not null set @fset = 1 else exec @fset = dbo.sp_MStestbit @setbm, ' + @colordstr +' if @fset <> 0 begin update ' + @qualified_name + ' set ' + @colname + ' = ' + @argname + ' where rowguidcol = @rowguid if (@@rowcount <> 1) set @failure = 1 end ' insert into #tempcmd (phase, cmdtext) values (7, @cmdpiece) end else begin -- for text and image, we just test if argument is null and whether bit is set -- build conditional update (phase 7) set @cmdpiece = ' if ' + @argname + ' is not null set @fset = 1 else exec @fset = dbo.p_MStestbit @setbm, ' + @colordstr + ' if @fset <> 0 begin update ' + @qualified_name + ' set ' + @colname + ' = ' + @argname + ' where rowguidcol = @rowguid if (@@rowcount <> 1) set @failure = 1 end ' -- Now insert the command to temp table insert into #tempcmd (phase, cmdtext) values (7, @cmdpiece) end -- Advance loop to next column and repeat! select @colid = min (colid) from syscolumns where id = @id and colid > @colid and iscomputed<>1 set @colnae = NULL if (@colid is not null) begin select @colname = QUOTENAME(name), @status = status, @typename = type_name(xtype), @blen = length, @prec = COLUMNPROPERTY(id, name, 'precision'), @scale = scale from syscolumns where id = @id and colid = @colid if @typename='nvarchar' or @t THe//)7SplitNextD0{1 e0{&/ -@- L0{2e0L0{3e0{0L0{4e0{+L0{5e* 0{-EYP0{6 e 0{.40{1e/)70{1V0<0{0b0{30EYypename='nchar' -- a unit of nchar takes 2 bytes set @len = @blen/2 else set @len = @blen set @colordinal = @colordinal + 1 end end -- Now we select out the command text pieces in proper order so that our caller, -- xp_execresultset will execute the command that creates the stored procedure. select cmdtext from #tempcmd order by phase, step sP0{9 b 0{7P0{: b0{:P0{; b0{; !P0{< b0{<40{/)70{f tMMPMMLtI@IHHXH HG|G4GD776t686p)$)((T((''D'T H 4 X``p 0@h 4\ -1, '@lineage_new') return (0) end if (not exists(select * from sysobjects where name = 'MSmerge_contents')) begin RAISERROR(20054 , 16, -1) return (0) end set @rowguidstr = '''' + convert(nchar(36), @rowguid) + '''' -- Are we just changing the type of a tombstone? if (@metadata_tbms vrMtybneec qh P0D'0{hTfl)7 user_transaction 0fEYt0f'0 **EY reurn XsZ 40fl)70(@f0D\ata_type = 6 and exists (select * from MSmerge_tombstone where rowguid = @rowguid and tablenick = @tablenick)) begin 00@g)7 grrevtyL0g\ 0zEY P0 g 0{= 40g)70dV0W0Xtion select @ownername = user_name(uid) from sysobjects where id = object_id(@tablename) select @procname = select_proc from sysmergearticles where objid = object_id(@tablename) and pubid = @pubid  +,0D c0{(AiZ/[\hM*7&sp_MSmakeselectproc R|0h+.C0&iZC@tablenamem\0h0{$6iZ$@tablename|0h0C0&iZC@ownername \0h0$6iZ$@ownername|0h0A0&iZA@procnametyp\0h0"6iZ"@procname P0hC 0{iZadaP0 hC 0 iZeleP0 hC0 iZurnP0 hF 0 iZ8bm 0 hiZ40 h.0X0*iZP M*7 Xsp_MSmakeselectprocl0h"0{46iZ4sp_MSmakeselectprocD0h[0{ iZHi/M*7SplitNextD0 i0{2/@L0iQL0iQ+L0i+Qcoto 0i0M 0 tZM create proc sp_MStable_not_modifiable @objid int, @columns binary(32) as declare @colname sysname declare @typestring nvarchar(4000) declare @src_cols int declare @this_col int declare @art_col int declare @isset int declare @found int, @repl_columns int select @this_col = 1 select @art_col = 1 select @found = 0, @repl_columns = 0 select @src_cols = count(*) from syscolumns where id = @objid while @this_col <= @src_cols begin exec @isset = dbo.sp_isarticlecolbitset @this_col, @columns if @isset != 0 and EXISTS (select name from syscolumns where id=@objid and @this_col=colid and iscomputed<>1) begin select @repl_columns = @repl_columns + 1 exec dbo.sp_MSget_type @objid, @this_col, @colname output, @typestring OUTPUT if @typestring = N'timestamp' or ColumnProperty(@objid, @colname, 'IsIdentity') = 1 select @found = 1 end select @this_col = @this_col + 1 end if @found = 1 and @repl_columns = 1 return 1 else return 0 <0 iQ0R x8L0i*0{6 tZJMP0 i 040iR*70V00hQ00iZ create procedure sp_MSmakeselectproc (@tablename sysname, @ownername sysname, @procname sysname) as declare @retcode smallint declare @argname nvarchar(10) declare @varname nvarchar(10) declare @cmdpiece nvarchar(4000) declare @qualified_name nvarchar(255) declare @column_list nvarchar(4000) declare @littlecomp nvarchar(300) declare @colid int declare @col_name sysname declare @id int set nocount on if @ownername is NULL or @ownername='' select @qualified_name = QUOTENAME(@tablename) else select @qualified_name = QUOTENAME(@ownername) + '.' + QUOTENAME(@tablename) select @id = object_id(@qualified_name) if @id is NULL return (1) /* ** Dynamically generate column list excluding computed columns */ if EXISTS (select name from syscolumns where id=@id and iscomputed=1) BEGIN select @column_list = '' DECLARE column_cursor CURSOR LOCAL FAST_FORWARD FOR select name from syscolumns where id=@id and iscomputed<>1 FOR READ ONLY open column_cursor fetch next from column_cursor into @col_name WHILE (@@fetch_status <> -1) BEGIN if LOWER(@col_name)='rowguid' select @col_name = 'rowguidcol' --Use alias to avoid conflict with #cont table else set @col_name = QUOTENAME(@col_name) if @column_list='' select @column_list = @col_name else select @column_list = @column_list + ', ' + @col_name fetch next from column_cursor into @col_name END close column_cursor deallocate column_cursor if @column_list='' begin RAISERROR(21125, 16, -1) return (1) end END else select @column_list = '*' /* ** Check for dbo permission */ exec @retcode=sp_MSreplcheck_subscribe if @retcode<>0 or @@ERROR<>0 return (1) set @cmdpiece = 'Create procedure dbo.' + QUOTENAME(@procname) + ' (@type int, @rowguid uniqueidentifier=NULL) AS declare @retcode int declare @objid int select @objid = object_id(''' + @qualified_name + ''') exec @retcode = dbo.sp_MSreplcheck_connection @objid=@objid if @@ERROR<>0 or @retcode<>0 return (1) if @type = 1 select ' + @column_list + ' from ' + @qualified_name + ' where rowguidcol = @rowguid else if @type < 4 select c.tablenick, c.rowguid, c.generation, c.lineage, c.colv1, ' + @column_list + ' from ' + @qualified_name + ' t, #cont c where t.rowguidcol = c.rowguid order by c.rowguid else if @type = 4 select 1 from ' + @qualified_name + ' where rowguidcol = @rowguid else if @type = 5 delete ' + @qualified_name + ' where rowguidcol = @rowguid else if @type = 6 -- sp_MSenumcolumns select ' + @column_list + ' from ' + @qualified_name + ' where 1=2 else if @type = 7 -- sp_MSlocktable select count(*) from ' + @qualified_name + '(tablock holdlock) where 1 = 2 else if @type = 8 -- put update lock if not exists (select * from ' + @qualified_name + '(UPDLOCK) where rowguidcol = @rowguid) RAISERROR(20031 , 16, -1)' exec (@cmdpiece) uP0 h 0P0 h0P0 h0 P0 h040hR*70́CV0+*t*$*)`Pl(00@h 4\ ** Check to see if the database has been activated for publication. */ IF (SELECT ca ,0D.0hTj*7 user_transaction 0jiZt0j.0 **iZbliati XUZ 40j*70(@f0D\ RETURN (1) END EXECUTE @retcode = dbo.sp_validname @publication IF @@ERROR <> 0 OR @retcode 00@k*7 grrevatL0k\ 0iZ P0 k 0 40k*70dV0m0X END EXECUTE @retcode = dbo.sp_changesubstatus @publication = @publication, @article = @article, @status = 'active', @from_auto_sync = 1 IF @@ERROR <> 0B0D c0(A/[h\\ly+7(sp_MSdropconstraintst0l$0;0&/[;@tableT0l06/[@tableP0l_ 0 /[8bmP0l_ 0/[P0l_ 0/[ 0l/[4Hm/y+7SplitNextD0  m0Z/ @ L0 mV*QL0 m0Q VpL0 mQ,O Ve0 mV0 +ZZZ^fT^ZV^fDLZX\fL^ZZTfHfZLPdRhdHbJZZZ^FVTh0*;dOZP y5Zsp_MSinsertcontentsc0*enZX N3 Zxp_ntsec_enumdomains 0*iZP M*7Zsp_MSmakeselectproc 0*xZS  2 ^SYSREMOTE_PRIMARY_KEYS'* tZP 6fsp_MStable_not_modifiableo0*ZP L2 Tsp_helpconstraint0*J~[P &6 ^sp_helppublicationsync 0*tC[P z5Zsp_MSupdatecontents-0*x[X /3 Vxp_ntsec_enumusers 0*Ȝ[S  82 SYSREMOTE_FOREIGN_KEYSe0*Y[P 6fsp_MSscript_sync_ins_proce0*[P M2 Dsp_helpdb0*\P 6 Lsp_MSreplrole0*7\P f{5Zsp_MSdeletecontents 0*׶l\X 3 Xxp_ntsec_enumgroups0*\U T2 \spt_datatype_info_ext0*\P u6fsp_MSscript_sync_upd_proc 0*+\P WN2 Lsp_helpdevice0*\P `6 ^sp_replicationdboption0*+]P G|5Zsp_MSunmarkifneeded u0*`]X 3 Zxp_terminate_proces0*:]U 2 Tspt_datatype_info0*]P V6fsp_MSscript_sync_del_proc0*d]P N2 Hsp_helpfile0*]P 6 fsp_addpublication_snapshot0*^P s}5Zsp_MSunmarkreplinfo@t0*IT^X 3 Lx_msx_enlist0*s ^U O2 Pspt_server_info0*^P 76dsp_MSgen_sync_tran_procs0*^P ~O2 Rsp_helpfilegroup0*.^P 56 hsp_MShelpobjectpublications0*X_P T~5dsp_MSaddanonymousreplica0*#I_X 3 Hxp_sqlmaint0*=)_P 6bsp_articlesynctranprocsM0*7_P P2 Jsp_helpgroup0*g3_P 6 Zsp_helpreplicationdb`0*=`P 5Zsp_MSgetreplicainfon0*G=`X 3 Zxp_get_mapi_profiles0*vM` 6^sp_reinitsubscription0*\`P P2 Fsp_helplog0*W`P e6 Vsp_helpdistributor0*a`P 5 Tsp_MSadd_repl_job0*k1aX I3 hxp_get_mapi_default_profile<0 m,0 V+~x8H0 /;dOZVP0 m040 my+70 V0+0lV 0Z0*/[P y+7 Zsp_MSdropconstraintslp0lY066/[6sp_MSdropconstraints D0l[0 /0lR+Z0/[Z -- This will be called merge at the subscriber side, check for dbo permission create procedure sp_MSdropconstraints @table sysname as declare @const_name sysname declare @objid int declare @retcode int /* ** Check for subscribing permission */ exec @retcode=sp_MSreplcheck_subscribe if @retcode<>0 or @@ERROR<>0 return (1) select @table=QUOTENAME(@table) set @objid = object_id(@table) if @objd is null return select @const_name = object_name(constid) from sysreferences where fkeyid = @objid while @const_name is not null begin exec ('alter table ' + @table + ' drop constraint ' + @const_name) if @@ERROR <> 0 return (1) set @const_name = NULL select @const_name = object_name(constid) from sysreferences where fkeyid = @objid end return (0) 6P0 l 0P0 l0P0 l0 P0 l040ly+70́CV08P8hp ,\ombstoneview = 'ts' + @guidstr select @genhistoryview = 'gh' + @guidstr select @filti[mPps^00DV 0Tn+7 user_transaction 0n/[t0nV 0 **/[bsto Zi\ut40n+70(@f0D\ return (1) exec @retcode = dbo.sp_MSuniqueobjectname @conte00@o,7 grrevRL0o\ 0/[ P0 o 0 40o,70dV0l0Xf @@ERROR<>0 OR @retcode<>0 return (1) exec @retcode = dbo.sp_MSuniqueobjectname @filtersview, @filte0D c0(Ah\ր]dp,7.sp_MSinsertschemachangeut0p<0;0&h\$$;@pubidnT0p+i 6h\@pubidt0p=0;0&h\$$;@artidrTp06h\@artid0p>0K0&h\88 K@schemaversion d0p0,6h\,@schemaversion0p?0E0&h\$$E@schemaguidt `0 p0&6h\&schemaguidh0 p@0 E0&h\88 E@schematype b`0 p0 &6h\&@schematypei0 pA0 E0&h\E@schematexton`0 p0 &6h\&@schematextIP0pu 0h\8bmquP0pu 0h\en 0ph\0pV0`0*h\P ,7 `sp_MSinsertschemachanget0p" 0<6h\<sp_MSinsertschemachangeD0p[0 h\0p+#0h\ CREATE PROCEDURE sp_MSinsertschemachange( @pubid uniqueidentifier, @artid uniqueidentifier = NULL, /* Can be NULL for directory commands */ @schemaversion int, @schemaguid uniqueidentifier, @schematype int, @schematext nvarchar(2000) ) as declare @retcode int /* ** Check for subscribing permission */ exec @retcode=sp_MSreplcheck_subscribe if @retcode<>0 or @@ERROR<>0 return (1) /* Parameter validation */ if (@scemaversion is null) begin RAISERROR(14043, 16, -1, '@schemaversion') return (1) end if (not exists(select * from sysobjects where name = 'MSmerge_contents')) begin RAISERROR(20001 , 16, -1) return (1) end insert into sysmergeschemachange with (HOLDLOCK TABLOCKX) (pubid, artid, schemaversion, schemaguid, schematype, schematext) values (@pubid, @artid, @schemaversion, @schemaguid, @schematype, @schematext) if @@error <> 0 begin RAISERROR(20001 , 16, -1) retrn (1) end /* update the schema version and schemaguid in MSmerge_replinfo */ declare @my_nickname int declare @srvid int select @srvid = 0 declare @repid uniqueidentifier select @my_nickname = replnickname, @repid = repid from MSmerge_replinfo where repid in (select subid from sysmergesubscriptions where srvid = @srvid and db_name = DB_NAME() and pubid = @pubid) update MSmerge_replinfo set schemaversion = @schemaversion where repid = @repid if @@error <> 0 begin RAISERROR(20001 , 16, -1) return (1) end update MSmerge_replinfo set schemaguid = @schemaguid where repid = @repid if @@error <> 0 begin RAISERROR(20001 , 16, -1) return (1) end return (0) P0 p 0P0 p0P0 p0 P0 p040p,70́CV0 00x(x8P4\>N P0 7 0p 40770dV0U0X!Z/ <H/7SplitNextD/# //k!@ uh$@00DV0Tq,7 user_transaction 0qh\t0qV0 **h\tgen `b40q,70(@f0D\artgen x080?0&J2O88 ?@cha00@r;-7 grrevaL0r\ 0h\ P0 r 0 40r;-70dV0m0Xx080?0&J2O88 ?@deletesVX0 8to0 6J2O @deletes0D c0(Aր]t^\s-7(sp_MSvalidatearticlet0sP0 ;0&ր]$$;@artidT0s+06ր]@artidt0sQ0;0&ր]$$;@pubid T0s,06ր]@pubid0sR0S0&ր]88 S@expected_rowcountel0s,046ր]4@expected_rowcount0sS0S0&ր]ll S@expected_checksuml0 s,046ր]4@expected_checksum0 sT0 O0&ր]88 O@validation_type0h0 s/0 06ր]0@validation_type0 sU0 I0&ր]00I@full_or_faste d0 s.0 *6ր]*@full_r_fastP0s 0ր]˧iTP0s 0ր]nP0s 0ր]P0s 0ր]P0s 0ր]}(ke 0sր]0sV0Z0*ր] -7 Zsp_MSvalidatearticleep0s]A0S66ր]6sp_MSvalidatearticle D0s[0 ր]0sS+.0ր] create procedure sp_MSvalidatearticle @artid uniqueidentifier, @pubid uniqueidentifier, @expected_rowcount int = NULL OUTPUT, @expected_checksum numeric = NUL OUTPUT, @validation_type int = NULL, @full_or_fast tinyint = 2 as -- get name of sync object and owner declare @objid int declare @syncobjid int declare @owner sysname declare @object sysname declare @view_type tinyint declare @temp_view tinyint declare @retcode int declare @rowcount_only bit /* ** Check to see if current publication has permission */ if @validation_type = 2 set @rowcount_only = 0 else set @rowcount_only = 1 exec @retcode=sp_MSreplcheck_connectin @pubid = @pubid if @retcode<>0 or @@ERROR<>0 return (1) select @syncobjid = sync_objid, @objid = objid, @view_type = view_type from sysmergearticles where pubid = @pubid and artid = @artid if (@syncobjid is not null and @syncobjid <> 0) set @objid = @syncobjid select @object = name, @owner = user_name(uid) from sysobjects where id = @objid -- if sync object is a temp view, we can't do this... set @temp_view = 2 if @view_type = @temp_view begin RAISERROR (20069 16, -1) return 1 end -- call sp_table_validation exec @retcode = dbo.sp_table_validation @object, @expected_rowcount OUTPUT, @expected_checksum OUTPUT, @rowcount_only, @owner, @full_or_fast return @retcode wP0 s 0P0 s0P0 s0 P0 s040s-70́CV0(8 TP`(8@H,\;z 0p&P@]y da 0;&P40;P80J0*&PP n7 Jsp_MSbelongsis`0;!;0<&6&P&sp_MSbelongs**D0;,oLPo0DV0Tt.7 user_transaction 0tր]t0tV0 **ր] Z\AI40t.70(@f0D\MD  L p(8h Hh$\ EXECUTE @retcode = dbo.sp_valid8P00@ug.7 grrevL0u\ 0ր] P0 u 0 40ug.70dV00Xbtype int = 4, /* Sub interval = Minute */ @freqsubinterval int = 5, /* Every five minutes */ @freqrelativeinterval int = 1, @freqrecurrencefactor int = 0,  0D c0(At^i_hv.74sp_MSsubscriptionvalidatedt0v+i ;0&t^$$;@subid T0vY06t^@subidt0v0;0&t^$$;@pubid5T0vY06t^@pubidP0v 0t^˧imal 0vt^0vV0f0*t^P .7 fsp_MSsubscriptionvalidatedrp|0 v]0B6t^Bsp_MSsubscriptionvalidatedliD0 v[0 t^X0 v+:0t^ create procedure sp_MSsubscriptionvalidated @subid uniqueidentifier, @pubid uniqueidentifier as /* ** Check to see if current publication has permission */ declare @retcode int exec @retcode=sp_MSreplcheck_connection @pubid = @pubid if @retcode<>0 or @@ERROR<>0 return (1) update sysmergesubscriptions set last_validated = getdate() where subid = @subid and pubid = pubid if @@rowcount <> 1 or @@error <> 0 begin RAISERROR (20070, 16, -1) return (1) end return (0) eP0 v 0P0 v0 P0 v0 P0 v040v.70́CV0l|$dT8\ibdb IS NULL BEGIN RAISERROR (14071, 16, -1) RETURN (1) END SELECT @database = DB_NAME() SELECT @distproc = RTRIM(@dist_rpcname) + '.' + @distribdb + '.dbo.sp_MSadd_snapshot_agent' SELECT @agent_args = '-Publisher ' + QUOTENAME(@@SERVERNAME) SELECT @agent_args = @agent_args + ' -PublisherDB ' + QUOTENAME(@database) SELECT @agent_args = @agent_args + ' -Distributor ' + QUOTENAME(@distributor) SELECT @agent_args = @agen@ 0DV0 TwH/7 user_transaction 0wt^t0wV0 **t^ fre f h, 40wH/70(@f0D\ = @freqsubtype, @freqsubinterval = @freqsubinterval, @freqrelativeinterval = @freqrelativeinterval, 00@x/7 grrevveL0x\ 0t^ P0 x 0 40x/70dV0m0X_jobid = @snapshot_jobid OUTPUT IF @@ERROR <> 0 or @retcode <> 0 GOTO UNDO -- Legacy, use non zero taskid to indicate agent already created at the distributor. UPDATE syspublicat :0D c0(Ai_LC]`hy/74sp_MSdroparticletombstonest0y0;0&i_$$;@artiduT0yi06i_@artid 0yi_0yV%0f0*i_P /7 fsp_MSdroparticletombstonesU|0yY0B6i_Bsp_MSdroparticletombstones D0y[0  i_0yT+M0i_ create procedure sp_MSdroparticletombstones @artid uniqueidentifier as declare @tablenick int select @tablenick = nickname from sysmergearticles where artid= @artid if @tablenick is not null begin delete from MSmerge_tombstone where tablenick = @tablenick delete from MSmerge_contents where tablenick = @tablenick delete from MSmerge_genhistory where art_nick=@tablenick end return (0) unP0 y 0P0 y0 P0 y0 40y/70x8x8L L8\queidentifier declare @guidstring nvarchar(38) declare @subset_filter nvarchar(4000) declare @tablename nvarchar(266) declare @join_table nvarchar(266) declare @boolean nvarchar(4000) declare @retcode smallint select @pubid = pubid from sysmergepublications where name = @publication and UPPER(publisher)=UPPER(@publisher) and publisher_db=@publisher_db /* Check for case of all rows - do I trust subset_type ? */ select @bool 0DV%0Tz)07 user_transaction 0zi_t0zV%0 **i_ste = fghate40z)070(@f0D\ (0) create table #probe (probe_id int identity NOT NULL, tablenick int NOT NULL, rowguid uniqueidentifier ROWGUIDCO00@{t07 grrev L0{\ 0i_ P0 { 0 40{t070dV0m0X return (1) set @guidstring = '''' + convert(nchar(36), @rowguid) + '''' /* If there is boolean filter, check for it being satisfied */ if @boolean is not null and @boolean <> ' ' begin exec (N 0D c0(ALC]`gQa\|07(sp_MSproxiedmetadata|0|00C0&LC]`88 C@tablenickj\0|z0$6LC]`$@tablenickx0|10?0&LC]`$$?@rowguidfX0|z0 6LC]` @rowguidx0|20?0&LC]`?@lineage X0|z0 6LC]` @lineaget0|3090&LC]`9@colv+ T0 |z06LC]`@colv+ P0 | 0LC]` Kboo 0 |LC]`40 |V+0Z0*LC]`P 07 Zsp_MSproxiedmetadata p0 |"#066LC]`6sp_MSproxiedmetadatajoD0|[0 LC]`0|V+i"0LC]` ceate procedure sp_MSproxiedmetadata @tablenick int, @rowguid uniqueidentifier, @lineage varbinary(256), @colv varbinary(2048) as declare @old_lin varbinary(256) declare @old_colv varbinary(2048) select @old_lin = lineage, @old_colv = colv1 from MSmerge_contents where tablenick = @tablenick and rowguid = @rowguid if (@old_lin IS NOT NULL) begin exec master..xp_proxiedmetadata @lineage out, @colv out, @old_lin, @old_colv update MSmerge_contents set lineage = @lineage, colv1 = colv where tablenick = @tablenick and rowguid = @rowguid end else begin select @old_lin = lineage from MSmerge_tombstone where tablenick = @tablenick and rowguid = @rowguid if (@old_lin IS NULL) return (0) exec master..xp_proxiedmetadata @lineage out, @colv, @old_lin, NULL update MSmerge_tombstone set lineage = @lineage where tablenick = @tablenick and rowguid = @rowguid end return (0) P0 | 0P0 |0P0 |0 P0 |040|070́CV0 P lhH0`4\lete temps if not nested */ EndLabel: if @nested = 0 begin drop table #found @r 0DV+0 T} 17 user_transaction 0}LC]`t0}V+0 **LC]` Z\40} 170(@f0D\40;n70Mae)<)((L(#p$@lineage,* ci = o s sa)@00@~ 17 grrevL0~\ 0LC]` P0 ~ 0 40~ 170dV0m0X JdLro40=70(@f0D\< datalength(@cvcurrent)) set @colv = @cvcurrent /* I 0D c0(AgQaEb\17&sp_MScontractsubsnbt0f0 ;0&gQa$$;@pubidT0s,6gQa@pubid|0g0C0&gQa88 C@tablenick>\s0$6gQa$@tablenickH/17SplitNextD0 0 /@L0&aL0 0apdL0 a+|0X,\70 0ndbelongsdl0?Y%0 26Q2sp_MSexpandbelongsoD0?[O0 Q0?L+0Q -- Modify temp table. No security check needed. create procedure sp_MSexpandbelongs @pubid uniqueidentifier AS declare @filterid int declare @retval int declare @expand_proc sysname /* We iterat over the join filters */ select @filterid = min(flag) from #belong select @filterid = min(join_filterid) from sysmergesubsetfilters where pubid = @pubid and join_filterid > @filterid and exists (select * from #belong where tablenick = join_nickname and flag < join_filterid) while (@filterid is not null) begin select @expand_proc = expand_proc from sysmergesubsetfilters where pubid = @pubid and join_filterid = @filterid exec @retval = @expand_proc @belong = 1 if @retval <> 0 retun (1) select @filterid = min(join_filterid) from sysmergesubsetfilters where pubid = @pubid and join_filterid > @filterid and exists (select * from #belong where tablenick = join_nickname and flag < join_filterid) end return (0) P0 ? 0P0 ?0 P0 ?0 40?70x8x8H,|(\0/.hTp7 user_transaction /B=t/BU0/B **=d X Z('d4/Bp7/B(@f0D\wner) = 1) begin raiserror(15000,-1,-1) return (1) end -- ERROR IF ROLE NOT FOUND -- if @uid is re 0DP?0T@7 user_transaction 0@Qt0@P?0 **Q VsXt *40@70(@f0D\rror(15144,-1,-1) select name = user_name(memberuid) from sysmembers where groupuid = @uid return (1) end 00@A+7 grrev>L0A\k 0Q P0 A 0 40A+70dV0"0XcEX/D`/. 6H+> @guidsrcp/D//D70&H+>88  P lhH|0X,@/ 6P/X. .00& drop procedure sp_MSsetupbelongs if exists (select * from sysobjects where type = 'P' and name = 'sp_MSexpandbelongs') drop procedure sp_MSexpandbelongs if exists (select * from sysobjects where type = 'P' and name = 'sp_MSexpandnotbelongs') drop procedure sp_MSexpandnotbelongs if exists (select * from sysobjects where type = 'P' and name = 'sp_MSenumpartial@eletes') drop procedure sp_MSenumpartialdeletes if exists (select * from sysobjects where type = 'P' and name = 'sp_MSsetlastsentgen') drop procedure sp_MSsetlastsentgen if exists (select * from sysobjects where type = 'P' and name = 'sp_MSdummyupdate') drop procedure sp_MSdummyupdate if exists (select * from sysobjects where type = 'P' and name = 'sp_MSdeletepushagent') drop procedure sp_MSdeletepushagent if exists (select * from sysobjects @where type = 'P' and name = 'sp_MScleanuptask') drop procedure sp_MScleanuptask if exists (select * from sysobjects where type = 'P' and name = 'sp_MSenumgenerations') drop procedure sp_MSenumgenerations if exists (select * from sysobjects where type = 'P' and name = 'sp_MScheckexistsgeneration') drop procedure sp_MScheckexistsgeneration if exists (select * from sysobjects where type = 'P' and name = 'sp_MSenumreplicas') drop procedure sp_MSenumrep@icas if exists (select * from sysobjects where type = 'P' and name = 'sp_MSenumdeletesmetadata') drop procedure sp_MSenumdeletesmetadata if exists (select * from sysobjects where type = 'P' and name = 'sp_MSenumchanges') drop procedure sp_MSenumchanges if exists (select * from sysobjects where type = 'P' and name = 'sp_MSenumpartialchanges') drop procedure sp_MSenumpartialchanges if exists (select * from sysobjects where type = 'P' and nam@ = 'sp_MSgetrowmetadata') drop procedure sp_MSgetrowmetadata if exists (select * from sysobjects where type = 'P' and name = 'sp_MSsetrowmetadata') drop procedure sp_MSsetrowmetadata if exists (select * from sysobjects where type = 'P' and name = 'sp_MSinsertgenhistory') drop procedure sp_MSinsertgenhistory if exists (select * from sysobjects where type = 'P' and name = 'sp_MSupdategenhistory') drop procedure sp_MSupdategenhistory if exists (select @ from sysobjects where type = 'P' and name = 'sp_MSenumschemachange') drop procedure sp_MSenumschemachange if exists (select * from sysobjects where type = 'P' and name = 'sp_MSupdateschemachange') drop procedure sp_MSupdateschemachange if exists (select * from sysobjects where type = 'P' and name = 'sp_MSadd_mergereplcommand') drop procedure sp_MSadd_mergereplcommand if exists (select * from sysobjects where type = 'P' and name = 'sp_MSsetreplica@nfo') drop procedure sp_MSsetreplicainfo if exists (select * from sysobjects where type = 'P' and name = 'sp_MSsetreplicastatus') drop procedure sp_MSsetreplicastatus if exists (select * from sysobjects where type = 'P' and name = 'sp_MScreateglobalreplica') drop procedure sp_MScreateglobalreplica if exists (select * from sysobjects where type = 'P' and name = 'sp_MSsetconflictscript') drop procedure sp_MSsetconflictscript if exists (select * from sysobHects where type = 'P' and name = 'sp_MSsetconflicttable') drop procedure sp_MSsetconflicttable P/  .P/ /P/ / b4.6.nae`p (14006, 16, -1) /* UNDONE : This code is specific to 6.X nested transaction semanticji*el dX/D .Tk6 user_transaction /0&t/ / **0&atio TV4/k6/(@f0D\blicationx.ic\.?0&C?@aP /D c.(A$')(`6,sp_MShelpmergearticles/E.G0&$'G@publication`/#(6$'(@publicationP/ $$' /@$'//^0*$'P 6 ^sp_MShelpmergearticles@t/Y>.:6$':sp_MShelpmergearticlesiD/Z1. $'/ /0$' CREATE PROCEDURE sp_MShelpmergearticles @publication sysname as declare @pubid uni@ueidentifier /* ** To public. */ if (@publication is null) begin RAISERROR(14003, 16, -1) return (1) end if (not exists(select * from sysobjects where name = 'MSmerge_contents')) begin RAISERROR(20054 , 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) begin RAISERROR (20026, 11, -1, @publication) return (1) @ end select a.name, o.name, user_name(o.uid), a.artid, a.pre_creation_command, a.pubid, a.nickname, a.column_tracking, a.status, a.resolver_clsid, a.conflict_script, a.conflict_table, a.insert_proc, a.update_proc, a.select_proc, a.destination_object, a.missing_col_count, a.missing_cols, c.name, a.article_resolver, a.resolver_info, a.subset_filterclause from sysmergearticles a, sysobjects o left outer join syscolumns c on o.id = c.id and ColumnProperty(o.id, c.name, 'IsRowGuidColH) = 1 where a.pubid = @pubid and o.id = a.objid order by a.nickname return (0) rP/  /P/ / P/ / P/ / 4/6/́CV0 P `\ <\ ' qX /D/T6 user_transaction /$'t// **$'_obid ^ `dec4/6/(@f0D\her can run this stored procedure */ if not exists (select * from sysobjects where name = 'sysmergepublications') X0/@I6 grrevENL/ .$' P/  / 4/I6/dV0"0X@@ERROR <> 0 or @retcode <> 0 return(1) /* ** Parameter Check: @filtername. ** The join_filter_name cannot be NULL */ if @filtername is NULL begin rP F / D c/(A)(b )T6 sp_MScreateretryP/ - /)(o P/ . / )(rt b / )(4/ /R0*)(P 6 Rsp_MScreateretryrnh@ !G. .6)(.sp_MScreateretry D/ Z8/  )(`/ F'0)(' CREATE PROCEDURE sp_MScreateretry as declare @tname sysname declare @pname sysname declare @tempname sysname declare @guid uniqueidentifier declare @guidstr varchar(40) declare @retcode smallint /* ** To public. */ set @guid = newid() e@ec @retcode=sp_MSguidtostr @guid, @guidstr out if @retcode<>0 or @@ERROR<>0 return (1) set @tempname = '##retry_' + @guidstr exec @retcode = dbo.sp_MSuniquetempname @tempname, @tempname out if (@@error <> 0) OR @retcode <> 0 begin RAISERROR(15001, 16, -1, 'sp_MSuniquetempname') return (1) end exec ('create table ' + @tempname + ' (tablenick int NOT NULL, rowguid uniqueidentifier ROWGUIDCOL default newid() not null, errcode int NOT NULL, errtext nvarchar(255) NULL, type tinyint NOT@NULL)' ) if (@@error <> 0) begin RAISERROR(15001, 16, -1, @tempname) return (1) end set @tname = @tempname set @tempname = '##insert_' + @guidstr exec @retcode = dbo.sp_MSuniquetempname @tempname, @tempname out if (@@error <> 0) begin RAISERROR(15001, 16, -1, 'sp_MSuniquetempname') return (1) end exec @retcode = dbo.sp_MSmaketempinsertproc @tname, @tempname if @@ERROR <>0 or @retcode<>0 return (1) select @pname = @tempname select @tname, @pname returnH(0) uP/  /P/ / P/ / 4/ 6/ ́CV0XdpP\D. j./all@catL.j/L.j/. x/X /%D/  bT*6 user_transaction /%)(t/%/% **)( R0T4/%*6/%(@f0D\y raiserror (14027, 11, -1, @join_articlename) X0/&@u6 grrevsL/& /)( P/&  / 4/&u6/&dV0I0X@join_nickname is NULL begin raiserror (20001, 11, -1, @article, @publication) P"/'D c/ (Ab )2*P6sp_MSdropretryt/' $5 ;0&b );@tname T/'$/6b )@tnamet/' /';0&b );@pname T/'@$/'6b )@pname /'b )/' /%N0*b )P 6 Nsp_MSdropretry d/'Y/*6b )*sp_MSdropretry D/' Z?/  b )T/' ()0b ) CREATE PROCEDURE sp_MSdropretry (@tna@e sysname, @pname sysname) as declare @retcode int /* ** To public */ exec ('drop table ' + @tname) if @@ERROR <> 0 return(1) exec ('drop procedure ' + @pname) if @@ERROR <> 0 return(1) return (0) iP/'  /&P/' /' P/' /' 4/'6/'x8Hx80H\<t \ begin raiserror (20002, 16, -1, @filtername, @article, @publication) return (1) end insert INTO sysmergesubsetfilters(filtername, pubid, artid, art_nickname, join_articlename, join_nimX/+D /'T 6 user_transaction /+b )t/+ /+ **b )e_ke N@P_f4/+ 6/+(@f0D\ if @@error <> 0 begin goto FAILURE X0/,@V6 grrevSL/, /&b ) P/,  /' 4/,V6/,dV0N0X(0) FAILURE: RAISERROR (20038, 16, -1, @article, @publication) return (1) UwP.! PB /-D c/'(A2*V*h64sp_MSchangearticleresolver/-/'Q0&2*Q@article_resolverl/-./'262*2@article_resolver/-/-M0&2*@M@resolver_clsidh/-//-.62*.@resolver_clsidit/-/-;0&2*$$;@artidT/-//-62*@artid/-/-K0&2*K@resolver_infod/@ 1/-,62*,@resolver_info /- 2*/- '/+f0*2*P 6 fsp_MSchangearticleresolver|/- !;/ B62*Bsp_MSchangearticleresolverD/- ZF/'  2*/-@02* CREATE PROCEDURE sp_MSchangearticleresolver ( @article_resolver nvarchar(255), @resolver_clsid nvarchar(40), @artid uniqueidentifier, @resolver_info sysname = NULL ) as if (@resolver_clsid='') select @resolver_clsid = NULL UPDATE sysmergearticles SET article_resolver = @article_resolver, resolver_clsid = @resolver_clsid, resolver_info = @resolver_info WHERE artid = @artid if @@ERROR <> 0 RETURN (1) return (0) P/H  /,P/- /-P/- /-4/-6/-x8x8H|\t DP\P.mP .|P. mQ . |e . m-#-PX /2D'/- T6 user_transaction /22*t/2'/2 **2* fh4/26/2(@f0D\Next8.n.)&V0L. n.P /3D c/-(AV* {+T6 sp_MSenumretriest/3 /- ;0&V*;@tnameT/38/- 6V*@tnamex/3!/3?0&V*88 ?@maxrowsSX/3@8/3 6V* @maxrows|/3"/3C0&V*88 C@tablenick \/39/3$6V*$@tablenickx/3#/3?0&V*$$?@rowguid X/3 9/3 6V* @rowguid /3 @V*/3 ./2R0*V*P 6 Rsp_MSenumretries h/3 Y/' .6V*.sp_MSenumretriesrD/3 ZM/- V*/3#0V* CREATE PROCEDURE sp_MSenumretries (@tname nvarchar(386), @maxrows int, @tablenick int, @rowgui@ uniqueidentifier) as declare @tnstring nvarchar(12) declare @rgstring nvarchar(38) declare @retcode int /* ** Modify temp table, granted to public. */ if (@tablenick < 1) begin set rowcount @maxrows execute ('select tablenick, rowguidcol, errcode, errtext, type from ' + @tname + ' order by tablenick, rowguidcol') IF @@ERROR <>0 RETURN (1) end else begin set rowcount @maxrows set @tnstring = convert(nchar, @tablenick) set @rgstring = '''' + conve@t(nchar(36), @rowguid) + '''' execute ('select tablenick, rowguidcol, errcode, errtext, type from ' + @tname + ' where (tablenick = ' + @tnstring + ' and rowguidcol > ' + @rgstring + ') or tablenick > ' + @tnstring + ' order by tablenick, rowguidcol' ) if @@ERROR <> 0 RETURN (1) end return (0) eP/3  /-P/3 /3P/3 H/34/36/3x8x84 D H Hx$\es @objid, '@', '_old', @indent, ' ' end %0-SQLTrace.dll<. n.p x8L.n)s.P. n .4.rdX /9D./3 T6 user_transaction /9V*t/9./9 **V* RnT 4/96/9(@f0D\ AS set nocount on /* ** Declarations. */ declare @pubid uniqueidentifier X0/:@c6 grrevjiL/: /,V* P/:  /3 4/:c6/:dV0i0X if not exists (select * from sysobjects where name = 'sysmergepublications') BEGIN RAISERROR (20054, 16, -1) RETURN (1) END /* ** Security CheckP /;D c/3(A {+F,T6 sp_MSdeleteretry|/;//3 C0& {+C@temptable \/;G/3 $6 {+$@temptableH/6SplitNextD/; . @/ @ L/;&L/;/; rrL/;( e L/; /;6GCKG=OCIGCEOKEA_[Q]ISYWSQOKKIEA7AKIEIGCE?A;A?I==IGCEKGI0&,GTABLE_SCHEMA 0&,@CTABLE_NAMEt0&, KPRIVILEGE_TYPE 0&,GIS_GRANTABLE 0&߭, =@Actionles0&߭,O@UserNamePatterns0&߭,C@LoginName)0&DZ-ITABLE_CATALOG 0&DZ-@GTABLE_SCHEMA 0&DZ-CTABLE_NAME 0&DZ-ECOLUMN_NAME -10&DZ-44OORDINAL_POSITIONn0&DZ-@KCOLUMN_DEFAULTd0&DZ-EIS_NULLABLEhe 0&DZ-ADATA_TYPEysm0&DZ-44 @_CHARACTER_MAXIMUM_LENGTHe0&DZ-44 [CHARACTER_OCTET_LENGTHf0&DZ-00 QNUMERIC_PRECISION 0&DZ-44 ]NUMERIC_PRECISION_RADIX r0&DZ-88 INUMERIC_SCALE 0&DZ-44SDATETIME_PRECISION0&DZ-@YCHARACTER_SET_CATALOG0&DZ-WCHARACTER_SET_SCHEMA0&DZ-SCHARACTER_SET_NAME0&DZ-QCOLLATION_CATALOGid0&DZ-OCOLLATION_SCHEMA 0&DZ-KCOLLATION_NAMEr0&DZ-@KDOMAIN_CATALOG0&DZ-IDOMAIN_SCHEMA0&DZ-EDOMAIN_NAME0&-A@loginame0&-7@map0&B.88 A@newvalue\0&'.KDOMAIN_CATALOGu0&'.IDOM@AIN_SCHEMA0&'.EDOMAIN_NAMEX0&'.ITABLE_CATALOGi0&'.GTABLE_SCHEMA0&'.CTABLE_NAME0&'.ECOLUMN_NAMEp0&Q.?@autofix0&{/88 A@newvalue@ti0& //;@login0& //A@password0& //88 ?@ver_old0& //00I@force_remove0&`/=GRANTOR0&`/=GRANTEE0&`/ITABLE_CATALOG0&`/@GTABLE_SCHEMA0&`/CTABLE_NAME0&`/ECOLUMN_NAME0&`/ KPRIVILEGE_TYPE0&`/GIS_GRANTABLE</; 5/;6x8L/; , ,P/; /:@4/;6/;V06|/;0/; C0& {+88 C@tablenick\/;G/;$6 {+$@tablenickx/;1/;?0& {+$$?@rowguiduX/;G/; 6 {+ @rowguid /@ {+/;5/9R0* {+P 6 Rsp_MSdeleteretry Nh/;!L/- .6 {+.sp_MSdeleteretry D/;ZT/3  {+`/;(1%0 {+% CREATE PROCEDURE sp_MSdeleteretry (@temptable nvarchar(386), @tablenick int, @rowguid un@queidentifier) as declare @guidstr nvarchar(38) declare @nickstr nvarchar(12) declare @retcode int /* ** Modify temp table, granted to public. */ set @nickstr = convert(nchar, @tablenick) set @guidstr = '''' + convert(nchar(36), @rowguid) + '''' execute ('delete from ' + @temptable + ' where tablenick = ' + @nickstr + ' and rowguidcol = ' + @guidstr) IF @@ERROR <>0 RETURN (1) return (0) P/;  /; HP/; /;P/; /;4/;6/;x8x8PP (PD`,\fier declare @artid uniqueidentifier declare @retcode int /* ** Security Check. */ exec @retcode = dbo.sp_MSreplcheck_publish if @@ERROR <> 0 or @i;X/ID5/;T6 user_transaction /I {+t/I5/I ** {+ Th @p RiTnot4/I6/I(@f0D\. */ if @publication is NULL begin raiserror (14003, 16, -1) return (1) X0/J@D6 grrev sL/J /: {+ P/J  /; 4/JD6/JdV0R0X26, 16, -1, @publication) return (1) end /* ** Parameter Check: @article. ** If an @article is specified, make sure it exists */ select @artid = artid from syP#&(/KD c/;(AF,-\6(sp_MSdeletepushagent|/K/; C0&F,C@publishera\/KS/;$6F,$@publisher/K/KI0&F,I@publ@isher_db= jd/KT/K*6F,*@publisher_dbge/K/KG0&F,G@publications`/KS/K(6F,(@publication/K/KE0&F,E@subscriber.ui`/K V/@&6F,&@subscriberid/K /K K0&F,K@subscriber_db d/K W/K ,6F,,@subscriber_dbP/K  / F,W` = P/K  /K F,( P/K /KF,@ts /KF,4/K</IZ0*F,P 6 Zsp_MSdeletepushagent fp/K!L/;66F,6sp_MSdeletepushagentd D/KZ[/; F,H/6SplitNextD/K /;/oin@filL/KGL/K$Gle =L/KG(4na /K/K0߭,CREATE PROCEDURE sp_change_users_login @Action varchar(10) -- REPORT / UPDATE_ONE / AUTO_FIX ,@UserNamePattern sysname = Null ,@LoginName sysname = Null@ AS -- SETUP RUNTIME OPTIONS / DECLARE VARIABLES -- set nocount on declare @exec_stmt nvarchar(430) declare @ret int, @FixMode char(5), @cfixesupdate int, -- count of fixes by update @cfixesaddlogin int, -- count of fixes by sp_addlogin @dbname sysname, @loginsid varbinary(85), @110name sysname -- SET INITIAL VALUES -- select @dbname = db_nam@(), @cfixesupdate = 0, @cfixesaddlogin = 0 -- ERROR IF IN USER TRANSACTION -- if @@trancount > 0 begin raiserror(15289,-1,-1) return (1) end -- INVALIDATE USE OF SPECIAL LOGIN/USER NAMES -- if @LoginName = 'sa' begin raiserror(15287,-1,-1,@LoginName) return (1) end if lower(@UserNamePattern) in ('dbo','guest','INFORMATION_SCHEMA') begin raiserror(15287,-1,-1,@UserNamePattern) @ return (1) end -- HANDLE REPORT -- if upper(@Action) = 'REPORT' begin -- VALIDATE PARAMS -- if @UserNamePattern IS NOT Null or @LoginName IS NOT Null begin raiserror(15290,-1,-1,@Action,@UserNamePattern,@LoginName) return (1) end -- GENERATE REPORT -- select UserName = name, UserSID = sid from sysusers where issqluser = 1 and (sid is not null and sid <> 0x0) and sus@r_sname(sid) is null order by name return (0) end -- HANDLE UPDATE_ONE -- if upper(@Action) = 'UPDATE_ONE' begin -- CHECK PERMISSIONS -- if not is_member('db_owner') = 1 begin raiserror(15288,-1,-1,'SA or DBO',@Action) return (1) end -- ERROR IF PARAMS NULL -- if @UserNamePattern IS Null or @LoginName IS Null begin raiserror(15290,-1,-1,@Action,@UserNamePatte@n,@LoginName) return (1) end -- VALIDATE PARAMS -- -- Can ONLY remap SQL Users to SQL Logins! Should be no need -- for re-mapping NT logins, and if you try, you'll mess up -- the user status bits! (see samsmith) if not exists (select name from sysusers where name = @UserNamePattern -- match user name and issqluser = 1) -- must be sql user begin raiserr@r(15291,-1,-1,'User',@UserNamePattern) return (1) end select @loginsid = sid from master.dbo.syslogins where loginname = @LoginName -- match login name and isntname = 0 -- cannot use nt logins if @loginsid is null begin raiserror(15291,-1,-1,'Login',@LoginName) return (1) end -- ERROR IF SID ALREADY IN USE IN DATABASE -- if exists (select @id from sysusers where sid = @loginsid and name <> @UserNamePattern) begin raiserror(15063,-1,-1) return (1) end -- CHANGE THE USERS LOGIN (SID) -- update sysusers set sid = @loginsid, updatedate = getdate() where name = @UserNamePattern and issqluser = 1 and sid <> @loginsid -- FINALIZATION: REPORT AND EXIT -- if @@error <> 0 or @@rowcount <> 1 raiserror(15295,-1,-1, @) else raiserror(15295,-1,-1, 1) return (0) end -- ERROR IF NOT AUTO_FIX -- if upper(@Action) <> 'AUTO_FIX' begin raiserror(15286,-1,-1,@Action) nd </K /Kx8L/K).F,eyP/K  /J4/K6/KV0 /K@/K 0F, /* ** This procedure is obselete for dropping push agent at distribution database. ** If we were to recover, don't use server id as parameter for RPC into distributor. ** Use server name instead. */ CREATE PROCEDURE sp_MSdele@tepushagent ( @publisher sysname, @publisher_db sysname, @publication sysname, @subscriber sysname, @subscriber_db sysname ) AS declare @distributor sysname declare @distribdb sysname declare @pubid uniqueidentifier declar@e @distproc nvarchar(512) declare @pub_srvid smallint declare @sub_srvid smallint declare @retcode smallint EXECUTE @retcode = dbo.sp_helpdistributor @distributor = @distributor OUTPUT, @distribdb = @distribdb OUTPUT IF @@ERROR <> 0 or @retc@ode <> 0 return (1) select @pub_srvid = srvid from master..sysservers where UPPER(srvname) = UPPER(@publisher) select @sub_srvid = srvid from master..sysservers where UPPER(srvname) = UPPER(@subscriber) select @pubid=pubid from sysmergepublicati@ons where name=@publication and UPPER(publisher)=UPPER(@publisher) and publisher_db=@publisher_db SELECT @distproc = RTRIM(@distributor) + '.' + RTRIM(@distribdb) + '.dbo.sp_MSdrop_agent_entry' EXEC @retcode = @distproc @pub_srvid, @publisher_db, @pu@blication, @sub_srvid, @subscriber_db IF @@ERROR <> 0 OR @retcode <> 0 return (1) return (0) P/K  /KP/K /KP/K /K P/K! /K!H4/K6/ḰCV0&%t%$%$`Px40p 8Xx4\member('securityadmin') = 1) AND not @loginame = suser_sname() begin raiserror(15132,-1,-1) return (1) end -- DISALLOW USER TRANSACTION -- set implicit_transactions off IF (@@trancount > 0) begin raiserror(15002,-1,-1,'sp_defaultdb') return (1) end -- VALIDATE DATABASE NAME -- if db_id(@defdb) I0sore e @(KX(/_D</KhT%6 user_transaction /_F,t/_</_ **F,ror150 Z1\e) 4/_%6/_(@f0D\DATABASE -- update master.dbo.sysxlogins set dbid = db_id(@defdb), xdate2 = getdate() where name = @loginame and sX0/`@p6 grrevetL/` /JF, P/`  /K" 4/`p6/`dV0X0X sysname, @login sysname, @reserved nvarchar(10) = NULL ) AS -- This stored pP /aD c/K(A-.P6sp_MSgetonerow|/a#/K C0&-88 C@tablenickt\/ar/K $6-$@tablenickx/a$/a?0&-$$?@rowguidMX@ar/a 6- @rowguidt/a%/a;0&-$$;@pubidbT/ar/a6-@pubidP/a (-˧ion /a -/a C/_N0*-P 6 Nsp_MS@etonerow-d/a Y6/3 *6-*sp_MSgetoneroweD/a Zb/K -/a H$R0-R CREATE PROCEDURE sp_MSgetonerow (@tablenick int, @rowguid uniqueidentifier, @pubid uniqueidentifier = NULL) as declare @retcode smallint declare @procname sysname /* ** Check to see if current publication has permission */ @ exec @retcode=sp_MSreplcheck_connection @tablenick = @tablenick if @retcode<>0 or @@ERROR<>0 return (1) select @procname = select_proc from sysmergearticles where nickname = @tablenick and pubid=@pubid exec @retcode = @procname @type =1, @rowguid=@rowguid IF @@ERROR<>0 or @retcode<>0 RETURN (1) return (0) P/a  /`P/a /aP/a H/a P/a /a4/a6/áCV08HxlT(\atalength(@login) select @db_len = datalength(@database) raiserror(916, 16, -1, @login_len, @login, @db_len,@database) re g/X /fDC/a TQ6 user_transaction /f-t/fC/f **- N P 4/fQ6/f(@f0D\ = @distribdb OUTPUT IF @@error <> 0 BEGIN X0/g@6 grrevrL/g /`- P/g  /a 4/g6/gdV050XISERROR (14071, 16, -1) return(1) END SELECT @distproc = RTRIM(@dist_rpcname) + '.P/hD c/a(A. /`26*sp_MSuplineageversionl|/h0/aC0&.88 C@tablenick \/h)h $6.$@tablenickx/h1/h?0&.$$?@ro@wguid X/h/h 6. @rowguidx/h2/h?0&.88 ?@version X/h/h 6. @versionP/h /a .˧isiP/h  /h .dlsP/h  /h@.rJ /h ./h J/f\0*.P 26 \sp_MSuplineageversionp/h ]3.86.8sp_MSuplineageversionD/hZi/a  ./h(V0. CREATE PROCEDURE sp_MSuplineageversio@ (@tablenick int, @rowguid uniqueidentifier, @version int) as declare @replnick int declare @curversion int declare @lineage varbinary(255) declare @retcode int declare @colv varbinary(2048) declare @col_tracking int /* ** Check to see if current publication has permission */ exec @retcode=sp_MSreplcheck_connection @tablenick = @tablenick if @retcode<>0 or @@ERROR<>0 return (1) exec dbo.sp_MSgetreplnick @nickname = @replnick out if (@@error <> 0) or @replnick IS @ULL begin RAISERROR (14055, 11, -1) RETURN(1) end if (@rowguid is null) begin RAISERROR(14043, 16, -1, '@rowguid') return (1) end if (@tablenick is null) begin RAISERROR(14043, 16, -1, '@tablenick') return (1) end select @col_tracking = column_tracking from sysmergearticles where nickname = @tablenick begin transaction -- get lineage, locking row in MSmerge_contents select @lineage = lineage, @colv = colv1 fr@m MSmerge_contents (UPDLOCK ROWLOCK index = 1) where tablenick = @tablenick and rowguid = @rowguid if (@lineage is null) begin commit RAISERROR(14043, 16, -1, '@rowguid') return (1) end set @curversion = 0 while (@curversion < @version) begin exec master..xp_updatelineage @lineage output, @replnick, @curversion output if (@col_tracking = 0) set @colv = NULL else set @colv = { fn UPDATECOLVBM(@colv, @replnick, 0x01, 0x00) } end update MSmerge_contents se@ lineage = @lineage, colv1 = @colv where tablenick = @tablenick and rowguid = @rowguid commit return (0) (@P/h  /gP/h /hP/h /h P/h /h4/h26/h́CV0 d  t HD$Hd 8\ and r.rkeyid not in (select objid from sysmergearticles where pubid = @pubid) select distinct ReferencedObject = object_name(fkeyid), ArticleObject = object_name(rkeyid) from sysreferences r where r.rkeyid in (select objid from sysmergearticles where pubid = @pubid) and r.fkeyid not in (select objid from sysmergearticles where pubid = @pubid) return (0) lP. w .4toNn X/pDJ/h T}6 user_transaction /p.t/pJ/p **.CJ0 \*^#"4/p}6/p(@f0D\NextD-, -m/ s@p_L-,ib 5vi/ X0/q@6 grrevL/q /g. P/q  /h 4/q6/qdV0H0X ^t``4.y6.(@Q0D\(@publication-F-E0&p P/rD c/h(A /*00X6$sp_MSgetlastrecgent/rA/h;0& /$$;@repid0T/r/h6 /@repidP/rE /h  / /r //r@Q/pV0* /P 6 Vsp_MSgetlastrecgenl/rY6/a 26 /2sp_MSgetlastrecgenD/rZp/h  //r I$50 / CREATE PROCEDURE sp_MSgetlastrecgen (@repid uniqueidentifier) as -- To public if (@repid is null) begin RAISERROR(140@3, 16, -1, '@repid') return (1) end if (not exists(select * from sysobjects where name = 'MSmerge_contents')) begin RAISERROR(20054 , 16, -1) return (1) end select recgen, recguid from MSmerge_replinfo where repid = @repid return (0) P/r  /qP/r /r P/r /r P/rH /r 4/r6/ŕCV0DT,||(\er bit declare @full int declare @subset int declare @unsynced int /* ** Initializations */ select @true = 1 select @false = 0 select @full = 0 /* Const: publication type 'full' */ select @subset = 1 /* Const: publication type 'subset' */ se 4X/vDQ/rT^6 user_transaction /v /t/vQ/v ** /(pulis VPXern4/v^6/v(@f0D\ BEGIN RAISERROR (20026, 16, -1, @publication) RETURN (1) END /* ** Set the X0/w@6 grrev L/w /q / P/w  /r 4/w6/wdV0&0X set @join_filter = @true /* ** For subset publications set the article status to be unsynced so that the triggers can be regenerated. */ if (@boolean_filter = 1 OR @join_filterP/xD c/r(A*00cT1\6&sp_MSgetlastsentgenyst/x/; ;0&*00$$;@repid T/x)/r6*00@repidP/xl /r*00 r /x*00/x@)X0**00P 6 Xsp_MSgetlastsentgenl/xY7/r46*004sp_MSgetlastsentgenD/xZw/r  *00/x (0*00 CREATE PROCEDURE sp_MSgetlastsentgen (@repid uniqueidentifier) as -- To public if (@repid is null) begin RAISERROR(1@043, 16, -1, '@repid') return (1) end if (not exists(select * from sysobjects where name = 'MSmerge_contents')) begin RAISERROR(20054 , 16, -1) return (1) end select sentgen, sentguid from MSmerge_replinfo where repid = @repid return (0) P/x  /wP/x /x P/x /x P/H /x 4/x6/x́CV0HX0,\indexcolfrombin|. }d ( C0&88 C@object_id\. }l.$6$@object_id|. }d . C0&88 C@cox4X/|D/xT?6 user_transaction /|*00t/|/| ***00& XZi4/|?6/|(@f0D\&?@colnameX.  }n.  6X0/}@6 grrevL/} /w*00 P/}  /x 4/}6/}dV0h0X }S(Z0*P r6 Zsp_MSindexcolfrombinp. }Y?. 66P%%&/~D c/x(AcT1x2T%6 sp_MSdummyupdatex/~%/x?0&cT1$$?@rowguidiX/~8/x 6cT1 @rowguid|/~&/~C0&cT188 C@tablenick@\@~9/~$6cT1$@tablenick|/~'/~A0&cT100A@metatypeP\/~8/~"6cT1"@metatype t/~(/~;0&cT1$$;@pubidT/~ 9/~6cT1@pubid|/@ )/~ C0&cT100C@uplineage\/~ </~ $6cT1$@uplineageP/~  /xcT1˧i 3P/~  /~ cT1pP/~ /~cT1dkP/~ /~cT1@ /~cT1/~ /|R0*cT1P %6 Rsp_MSdummyupdateh/~Y/x.6cT1.sp_MSdummyupdateD/~Z~/x  cT1H/%6SplitNextD/~ /K/@,L/~@L/~( L/~$`P /~/~@-0X1@ --Identifies user defined datatype accessible to current user, that have constraints create view INFORMATION_SCHEMA.DOMAIN_CONSTRAINTS as select DB_NAME() as CONSTRAINT_CATALOG ,USER_NAME(obj.uid) as CON@TRAINT_SCHEMA ,obj.name as CONSTRAINT_NAME ,DB_NAME() as DOMAIN_CATALOG ,USER_NAME(typ.uid) as DOMAIN_SCHEMA ,typ.name as DOMAIN_NAME ,'NO' as IS_DEFERRABLE ,'NO' as INITIALLY_DEFERRED FROM sysobjects obj, systypes typ WHERE obj.xtype = 'R' and obj.id = typ.domain AND typ.xusertype > 256 -- UDF Type 0b1-CREATE PROCEDURE sp_srvrolepermission @srvrolename sysname = NULL AS if @srvrolename is not null begin -- VALIDATE GIVEN NAME if not@exists (select * from master.dbo.spt_values where name = @srvrolename and low = 0 and type = 'SRV') begin raiserror(15412, -1, -1, @srvrolename) return (1) end -- RESULT SET FOR SINGLE SERVER-ROLE select 'ServerRole' = v1.name, 'Permission' = v2.name from master.dbo.spt_values v1, master.dbo.spt_values v2 where v1.name = @srvrolename and v1.low = 0 and v1.type = 'SRV' and ((v2.type = 'SRV' and ((v1.number = 16 and v1.number <= v2.number) or (v1.num@er <> 16 and v1.number = v2.number))) or (v2.type = 'DBR' and v1.number = 16)) and v2.low > 0 order by v1.name, v2.name end else begin -- RESULT SET FOR ALL SERVER-ROLES select 'ServerRole' = v1.name, 'Permission' = v2.name from master.dbo.spt_values v1, master.dbo.spt_values v2 where v1.low = 0 and v1.type = 'SRV' and ((v2.type = 'SRV' and ((v1.number = 16 and v1.number <= v2.number) or (v1.number <> 16 and v1.number = v2.number))) or (v2.type =@'DBR' and v1.number = 16)) and v2.low > 0 order by v1.name, v2.name end return (0) -- sp_srvrolepermission _0^1 create proc sp_MSdoesfilterhaveparent @filter_id int as declare @retcode int exec @retcode = dbo.sp_MSreplcheck_publish if @@ERROR <> 0 or @retcode <> 0 return(1) if exists ( select * from sysobjects where id = @filter_id and parent_obj <> 0 ) BEGIN return 1 END ELSE@ BEGIN return 0 END </~ /~ x8L/~)/KX1aP/~  /}4/~%6/~V0/~/~0cT1 CREATE PROCEDURE sp_MSdummyupdate (@rowguid uniqueidentifier, @tablenick int, @metatype tinyint, @pubid uniqueidentifier @ NULL, @uplineage tinyint = 1) as declare @retcode int declare @lineage varbinary(255) declare @mynickname int declare @objid int declare @col_tracking int declare @ccols int declare @missing_count int declare @colv varbinary(2048) /* ** Check to see if current publication has permission */ exec @retcode=sp_MSreplcheck_connection @tablenick = @tablenick if @retcode<>0 or @@ERROR<>0 return (1) /* Parameter checks */ if (@rowguid is null) begin RAISERROR(14043, 16@ -1, '@rowguid') return (1) end if (@tablenick is null) begin RAISERROR(14043, 16, -1, '@tablenick') return (1) end if (@metatype is null) begin RAISERROR(14043, 16, -1, '@metatype') return (1) end /* Check if we have a merge publication by whether system table is there */ if (not exists(select * from sysobjects where name = 'MSmerge_contents')) begin RAISERROR(20054 , 16, -1) return (1) end exec dbo.sp_MSgetreplnick @nickname = @mynickname out if (@@error <> 0) or @mynickname IS NULL begin RAISERROR (14055, 11, -1) RETURN(1) end if (@metatype = 0) or @@ERROR<>0 begin declare @reason nvarchar(255) /* We don't have the row. Putting in a system delete tombstone should cause a delete and ** eventual convergence. We are already logging the row as a conflict / error. */ set @lineage = { fn UPDATELINEAGE(0x0, @mynickname) } select @reason = formatmessage(20562) insert @nto MSmerge_tombstone (rowguid, tablenick, type, lineage, generation, reason) values (@rowguid, @tablenick, 6, @lineage, 0, @reason) end else if (@metatype = 1) begin /* Update systombstone */ select @lineage = lineage from MSmerge_tombstone (UPDLOCK ROWLOCK index = 1) where tablenick = @tablenick and rowguid = @rowguid if (@uplineage = 1) begin set @lineage = { fn UPDATELINEAGE(@lineage, @mynickname) } end update MSmerge_tombstone set generation = 0, lineage@= @lineage where tablenick = @tablenick and rowguid = @rowguid end else if (@metatype = 2) begin /* Update MSmerge_contents */ select @lineage = lineage, @colv = colv1 from MSmerge_contents (UPDLOCK ROWLOCK index = 1) where tablenick = @tablenick and rowguid = @rowguid if (@uplineage = 1) begin set @lineage = { fn UPDATELINEAGE(@lineage, @mynickname) } if @pubid is NULL select @objid = objid, @col_tracking = column_tracking, @missing_count = missing_col_count @ from sysmergearticles where nickname = @tablenick else select @objid = objid, @col_tracking = column_tracking, @missing_count = missing_col_count from sysmergearticles where nickname = @tablenick and pubid = @pubid if (@col_tracking = 0) set @colv = NULL else set @colv = { fn UPDATECOLVBM(@colv, @mynickname, 0x01, 0x00) } end update MSmerge_contents set generation = 0, lineage = @lineage, colv1 = @colv where tablenick = @tablenick and rowguid = @rowguid @ end else if (@metatype = 3) begin set @lineage = { fn UPDATELINEAGE(0x0, @mynickname) } if @pubid is NULL select @objid = objid, @col_tracking = column_tracking, @missing_count = missing_col_count from sysmergearticles where nickname = @tablenick else select @objid = objid, @col_tracking = column_tracking, @missing_count = missing_col_count from sysmergearticles where nickname = @tablenick and pubid = @pubid if (@col_tracking = 0) set @colv = NULL else begi@ select @ccols= count(*) from syscolumns where id = @objid set @ccols = @ccols + @missing_count set @colv = { fn INITCOLVS(@ccols, @mynickname ) } end insert into MSmerge_contents (tablenick, rowguid, lineage, generation, colv1) values (@tablenick, @rowguid, @li+ /~/~e0cT1eneage, 0, @colv) end return (0) P/~  /~HP/~! /~!P/~" /~" P/~# /~#4/~%6/~s @%$d$$#$#4d(@h$0p t0X(\1) exec dbo.sp_MSindexcolfrombin @join_objidn i@,= b S~/X&/D /~x8Tk6 user_transaction /cT1t/ / **cT1set RlTce4/k6/(@f0D\ + ' = ' + @join_table + '.' + @joincol /* X0/@6 grrevsL/ /}cT1 P/  /~$ 4/6/dV0\0X set @filtclause = @filtclause + ' and ' + @filtpiece /* move on to the next key */ PX /D c/~(Ax2՜3XL6$sp_MSsetlastrecgent/5/~ ;0&x2$$;@repidlT/H/~ 6x2@repidx/6/=0&x288 =@srcgenetX/@I/6x2@srcgenx/7/?0&x2$$?@srcguidX/J/ 6x2 @srcguidP/ )) x2˧iP/  / x2H / x2/ @V0*x2P L6 Vsp_MSsetlastrecgenl/ ]/h26x22sp_MSsetlastrecgenD/ Z/~ x2/$`h0x2h CREATE PROCEDURE sp_MSsetlastrecgen (@repid uniqueidentifier, @srcgen int, @srcguid uniqueidentifier) as /* ** Check to see if current publica@ion has permission */ declare @retcode int exec @retcode=sp_MSreplcheck_connection @repid = @repid if @retcode<>0 or @@ERROR<>0 return (1) if (@repid is null) begin RAISERROR(14043, 16, -1, '@repid') return (1) end if (@srcgen is null) begin RAISERROR(14043, 16, -1, '@srcgen') return (1) end if (@srcguid is null) begin RAISERROR(14043, 16, -1, '@srcguid') return (1) end if (not exists(select * from sysobjects where name = 'MSmerge_contents')) beg@n RAISERROR(20054 , 16, -1) return (1) end update MSmerge_replinfo set recgen = @srcgen, recguid = @srcguid where repid = @repid IF @@ERROR <>0 return (1) return (0) P/  /P/ /P/ / P/ /4HL6/́CV0 \ llL|(\ P.$ v .$   .$  4.$S.#X0* P 96 Xsp_MSmakeexpandprocl.$YI.46 4sp_MSmakeexpandprocD.$/it/X /D/ T6 user_transaction /x2t// **x2 VXk_4/6/(@f0D\;  .$.$Fw 0F----------------------X0/@6 grrevR L/ /x2 P/  / 4/6/dV0P0X -- MUST BE NT NAME -- if (charindex('\', @ntname) = 0) return (1) declare @newsid varbinary(85), @status smallint, @uid smallint Xz/`.-6 get_sid('\U'+@ntname, NULL) -- NT user if (@newsid is Null) begin select @newsid = get_sid('\G'+@ntname, NULL) -- NT group IF (@newsid IS Null) return (1) end else select @status = @status | 8 -- NTUser -- FAIL IF SID ALREADY IN SYSUSERS -- if exists (select sid from sysusers where sid X//6/hq  select @uid = min(uid)+1 from sysusers where uid >= 5 and uid < (16384 - 1) -- stay in users range and user_name(uid+1) is null -- uid not in use if @uid is null begin raiserror(15065,-1,-1) return (1) end -- ADD IMPLICIT SYSUSERS ENTRY -- inserPh /D c/(A՜3~4\/6&sp_MSsetlastsentgen t/F/;0&՜3$$;@repidT/Y/6՜3@repidx/G/=0&՜388 =@srcgeneinX/@Z/6՜3@srcgenshx/H/?0&՜3$$?@srcguidbX/[/ 6՜3 @srcguidP/& / ՜3˧iL RP/ & / ՜3s", / ՜3/ @/X0*՜3P /6 Xsp_MSsetlastsentgenl/ ]/ 46՜34sp_MSsetlastsentgenD/ Z/ ՜3/(r0՜3r CREATE PROCEDURE sp_MSsetlastsentgen (@repid uniqueidentifier, @srcgen int, @srcguid uniqueidentifier) as /* ** Check to see if current pu@lication has permission */ declare @retcode int declare @pubid uniqueidentifier exec @retcode=sp_MSreplcheck_connection @repid = @repid if @retcode<>0 or @@ERROR<>0 return (1) if (@repid is null) begin RAISERROR(14043, 16, -1, '@repid') return (1) end if (@srcgen is null) begin RAISERROR(14043, 16, -1, '@srcgen') return (1) end if (@srcguid is null) begin RAISERROR(14043, 16, -1, '@srcguid') return (1) end if (not exists(select * from sysobject@ where name = 'MSmerge_contents')) begin RAISERROR(20054 , 16, -1) return (1) end -- check for setting a sentgen which is obviously too high select @pubid = pubid from sysmergesubscriptions where subid = @repid if (exists (select * from MSmerge_genhistory where generation < @srcgen and guidlocal = '00000000-0000-0000-0000-000000000000' and (art_nick = 0 or art_nick is null or art_nick in (select nickname from sysmergearticles where pubid = @pubid) ))) begin R@ISERROR('Setting sentgen too high', 16, -1) return (1) end update MSmerge_replinfo set sentgen= @srcgen, sentguid = @srcguid where repid = @repid IF @@ERROR <>0 return (1) return (0) P/  /P/ /P/ / P/ /H4//6/́CV0 l  pp P,\4.$96.$V0.$;.$0  create procedure sp_MSmakeexpandproc @pubname sysname, @filterid int, @procname sysname AS /* Declare additional variables */ declare @pubid uniqueidentifier declare @base_nick int declare @join_nick int AsbX/D/ Tz6 user_transaction /՜3t// **՜3ame XrZlau4/z6/(@f0D\ust_check int declare @view_type int declare @guidcolname sysname declare @view_objid int declare @viX0/@6 grrevroL/ /՜3 P/  / 4/6/dV0B0Xmmand pieces into it, and select them out -- create temp table to select the command text out of create table #tempcmd (step int identity NOT NULL, cmdtext nvarchar(4000) NULL) /* FiguPb/D c/(A~4Gr5T[6 sp_MScleanuptaskt/)h ;0&~4$$;@pubideT/e/6~4@pubidP/8 / ~4˧i whP/8 /@~4AME /~4H/[6SplitNextD/ /~Y/id)@ frL/ U*L/ /idU, L/ *) U- / U/ ,HVTjf<N\HVhRJ^Nph@VPHbVFLTNRbHP^ddfTJXJh^ZLZV00*|6P 2 Hsp_helprole0*6P \6Vsp_addpublication @0*C"6P o22 Tsp_user_counter100*6P  5jsp_MS_replication_installed1 0*'7X T5 fxp_trace_getqueueautostartet@*(2;7V $a3 <VIEWS0*R0*:X V5 bxp_trace_setqueryhist@ryar0* ;X 3 Hxp_regwrite0*6@;P Ε2 Psp_serveroption0*`;P Ub6^sp_helparticlecolumnsca0*`u;P 62 dsp_fallback_MS_sel_fb_svr0*ҕ;P -5 dsp_MSregistersubscription0*;X uW5 fxp_@race_flushqueryhistoryrg0*E;X U3 Txp_regdeletevalue0*o4

0 or @@ERROR<>0 return (1) set nocount on if (@pubid is null) begin RAIS@RROR(14043, 16, -1, '@pubid') return (1) end if (not exists(select * from sysobjects where name = 'MSmerge_contents')) begin RAISERROR(20054 , 16, -1) return (1) end declare @cutoff datetime /* ** Bypass task cleanup if retention value is 0; Null value has been converted to 0 */ select @retention = retention from sysmergepublications where pubid = @pubid if @retention = 0 return (0) select @cutoff = dateadd(dd, -@retention, getdate()) delete from MSmerge_genh@story where coldate < @cutoff declare @mingen int select @mingen = min(generation) from MSmerge_genhistory delete from MSmerge_tombstone where generation > 0 and generation < @mingen IF @@ERROR <>0 return (1) return (0) P/  /P/ /P/ / P/ /H4/[6/́CV0(8\rt into #tempcmd(cmdtext) values (@cmd_piece) end -- else we don't bother expanding #notbelong for this filter since there are cyclic -- join filters and this is not a unique key join. The cursored calls to sp_belongs -- are unacceptably slow, and there would still be cases where orphaned rows could occur. -- Now we select out the command text pieces in proper order so thiEX/D /T6 user_transaction /~4t/ / **~4 RT4/6/(@f0D\P.; .;4.$96.$ X0/@6 grrevubL/ /~4 P/  / 4/6/dV0"0X db_name, pubid, status, subscriber_type, uid P/D c/(AGr5 g6\<6(sp_MSenumgenerations|//A0&Gr588 A@genstart\/x/"6Gr5"@genstart t//;0&Gr5$$;@pubi@dT/y/6Gr5@pubidP/G /Gr5xP/H /Gr5~4 /Gr5/ '/Z0*Gr5P <6 Zsp_MSenumgenerationsH/<6SplitNextD/@ / &/@L/ "Y]L/ Y/~]e"sP/ /L/]/ x8Yp"n/"/ D:FD(>6,H4:*$F*2444&8(48..<6*$@N><:.>4J0@4:40>D2@@<8::F,44FF2F6H@@@@@x86$':sp_MShelpmergearticles6[Fsp_MShelpmergeconflictcounts6.^Dsp_MShelpobjectpublications6Bm(sp_MShelptype6ZZ>sp_MSIfExistsRemoteLogin766sp_MSindexcolfrombin--6sp,sp_MSindexspace65Hsp_MSinit_replication_per@mon6;dOZ4sp_MSinsertcontents6 PQ:sp_MSis_col_replicated t6.DR*sp_MSis_pk_colE 6=z$sp_MSkilldb6٥ Fsp_MSload_replication_status--6 ;f*sp_MSlocktablele6y2sp_MSloginmappingsso6 4sp_MSmakeexpandproc6yRz4sp_MSmakegeneration64sp_MSmakejoin@ilter6$.}&sp_MSmaptype i6XR8S8sp_MSmark_proc_norepl6d8u(sp_MSmatchkey6`A4sp_MSmergepublishdb6Z>p8sp_MSmergesubscribedb60b{.sp_MSobjectprivsNT6..sp_MSpad_commandra6|<sp_MSpublicationcleanup6{| 6sp_MSpublicationviewgr6TL*sp_MSpublishdbm @v$sp_MSrefcnt6ҕ;@sp_MSregistersubscription6eNsp_MSreinit_failed_subscriptions 6(k_+>sp_MSremovedbreplication 6 &<sp_MSrepl_addrolemember6GNA:sp_MSrepl_check_server 6mR.sp_MSrepl_dbroleD 6Dڎ'>sp_MSrepl_droprolemember= 6?r>4sp_MSrepl_i@dbowner6Ff8Jsp_MSrepl_linkedservers_rowset6n0sp_MSrepl_startup6˧i@sp_MSreplcheck_connection6劖T4sp_MSreplcheck_name6e:sp_MSreplcheck_publishmp6̅j4sp_MSreplcheck_pull6=yk0sp_MSreplcheck_qv68bm>sp_MSreplcheck_subscribeul6\VnDsp_MSrepl@cationcompatlevel6@92sp_MSreplraiserrorUS6\(sp_MSreplrole63@sp_MSreplsup_table_has_pk6BB<sp_MSreset_synctran_bit6uW8sp_MSscript_beginproc6z,:sp_MSscript_begintrig1r 6P:sp_MSscript_begintrig2 6<WFsp_MSscript_delete_statement@@69@sp_MSscript_dri6OY4sp_MSscript_endproc6t4sp_MSscript_endtrig6ʚ UFsp_MSscript_insert_statementte6LFsp_MSscript_multirow_trigger 6A 2sp_MSscript_paramst 6cf?Fsp_MSscript_pkvar_assignmentt 6+X6sp_MSscript_security 6{rXHsp_MSscript_singler@w_trigger6]@sp_MSscript_sync_del_proc6_)@sp_MSscript_sync_del_trig6Y[@sp_MSscript_sync_ins_proc6@@sp_MSscript_sync_ins_trig6\@sp_MSscript_sync_upd_proc</ YD/"Dx8t/.<6"<sp_MShelpmergearticl@sP/ /4/ <6/ V0Dp/ Y/66Gr56sp_MSenumgenerations lD/Z/ Gr5/( 0Gr5 CREATE PROCEDURE sp_MSenumgenerations (@genstart int, @pubid uniqueidentifier) as declare @retcode smallint @/* ** To public */ if (@genstart is null) begin RAISERROR(14043, 16, -1, '@genstart') return (1) end if (@pubid is null) begin RAISERROR(14043, 16, -1, '@pubid') return (1) end if (not exists(select * from sysobjects where name = 'MSmerge_contents')) begin RAISERROR(20054 , 16, -1) return (1) end exec @retcode = dbo.sp_MScleanuptask @pubid if @@ERROR<>0 or @retcode<>0 begin return (1) end select DISTINCT generation, guidsrc, art_nick, guid@ocal from MSmerge_genhistory where generation >= @genstart and (art_nick = 0 or art_nick is NULL or art_nick in (select nickname from sysmergearticles where pubid = @pubid)) ORDER BY generation ASC IF @@ERROR <>0 return (1) return (0) tetP/  /P/ /P/ / P/ H/4/<6/́CV0@P<TTl 8X4\ open PC fetch PC into @publication, @pubid, @retention select @minus_retention2 = dateadd(day, -@retention * 2, getdate()) select @minus_retention = dateadd(day, -@retention, getdate()) WHILE (@@fetch_status <> -1) BEGIN if @retention is not NULL and @retention > 0 l eo,is6ff( X/D'/ T6 user_transaction /Gr5t/'/ **Gr5atu, @ Zp\ 4/6/(@f0D\IN select @subscriber=srvname from master..sysservers where srvid=@subscriber_id X0/@6 grrev L/ /Gr5 P/  / 4/6/dV0/Xntgen from MSmerge_replinfo where repid=@subid select @send_ts = coldate from MSmerge_genhistory where generation=@sentgen if @receive_ts>@send_ts select @recent_mP/D c/(A g6-[7h74sp_MScheckexistsgenerationx/$/?0& g6$$?@genguid X// 6 g6 @genguidp/%/70& g688 7@ge@ncP//6 g6@gent/&/;0& g6$$;@pubiduH/7SplitNext8/.V0L/  / /D/  / /@98/  !@x8L/  L/ /_lP/ /L/)b  // ^&(4.2" ($*""($*,4.2*$(""("..&4.2*$( "0&&06(:.4($&$("((*$(."(@&*"*$(("&"$ "(& &*$(("& a06)3&@trigger_ida6}^4(CHECK_CLAUSE6}^44CONSTRAINT_CATALOG6}^4.CONSTRAINT_NAME 6}^42CONSTRAINT_SCHEMAC6~4@pubid6ϓ4"@rolenamef68˳4 @article68˳4(@publication68˳4$@publisher68˳4*@publisher_db 64@"@newvalue 6b4@login6b4"@password 6b4(@publication6b4$@publisher6b4*@publisher_dbC6b4,@security_mode6R54CONSTRAINT_CATALOG6R5.CONSTRAINT_NAME6R52CONSTRAINT_SCHEMA6R5*TABLE_CATALOG6R5$TABLE_NAME6R5(TABL@_SCHEMA6Gr5"@genstart6Gr5@pubid65"@rolename6q5(@publication6 5"@newvalue65.@property_table65.@tran_sub_table 6 G6&COLUMN_NAMEb6 G64CONSTRAINT_CATALOG6 G6.CONSTRAINT_NAMEh6 G62CONSTRAINT_SCHEMA6 G6*TABLE_CA@ALOG,6 G6$TABLE_NAME6 G6(TABLE_SCHEMA6 g6@gen6 g6 @genguid6|6"@rolename 66 0@allow_anonymous66 &@allow_pull66 &@allow_push660@allow_sync_tran666@autogen_sync_procs66(@description66 :@enabled_for_internet @6 .@immediate_sync664@independent_agent66(@publication66$@repl_freq66&@restricted66$@retention66@status@66(@sync_method66@taskid6C"6"@newvaluei6(2;7(CHECK_OPTION6(2;7(IS_UPDATABLE6(2;7*TABLE_CATALO@6(2;7$TABLE_NAME6(2;7(TABLE_SCHEMA6(2;7.VIEW_DEFINITION6R '00000000-0000-0000-0000-000000000000' and ((pubid = @pubid) or (pubid is null)) IF @@ERROR <>0 return (1) return (0) retP/  /P/ /P/ /4/7/x8x80pPxD\HT<\u/G6TEX/D./Th7 user_transaction / g6t/./ ** g6 ins fohd (4/h7/(@f0D\re pubid = @pubid and len(subset_filterclause) > 0 insert into #unfiltered (object_id, art_name) select objid, X0/@7 grrevt_L/ / g6 P/  / 4/7/dV0c0X rkeyid = fkeyid) select @distance = min(distance) from #filtered f, sysreferences r, #unfiltered u where (f.object_id = r.rkeyid and r.fkeyid = u.object_id) or (u.object_id = r.rkeyidP /D c/(A-[7QO8X7"sp_MSenumreplicasyit/?/;0&-[7$$;@pubideT/A/6-[7@pubidP/z /-[7jid /-[7/@U/ T0*-[7P 7 Tsp_MSenumreplicash/Y/06-[70sp_MSenumreplicasD/Z/ -[7/ )0-[7 CREATE PROCEDURE sp_MSenumreplicas (@pubid uniqueidentifier) as declare @active tinyint declare @deleted tinyint /* ** To public @*/ select @active = 1 select @deleted = 2 if (not exists(select * from sysobjects where name = 'MSmerge_contents')) begin RAISERROR(20054 , 16, -1) return (1) end select subs.subid, replinfo.replnickname, subs.subscriber_type, subs.subscription_type, subs.priority, replinfo.schemaversion, replinfo.schemaguid, subs.datasource_type, subs.datasource_path, servers.srvname, subs.db_name, subs.status, subs.partnerid, subs.sync_type, subs.description, subs.pubid from sysmergesu@scriptions subs, MSmerge_replinfo replinfo, master..sysservers servers where replinfo.repid = subs.subid and subs.srvid = servers.srvid and (subs.status = @active or subs.status=@deleted) and subs.subscriber_type = 1 and (subs.pubid is null or exists (select * from sysmergearticles art1, sysmergearticles art2 where art1.pubid = subs.pubid and art2.pubid = @pubid and art1.artid = art2.artid)) order by convert(binary, subs.subid) IF @@ERROR <>0 return (1) Heturn (0) P/  /P/ / P/ / P/ / 4/7/́CV0L \ $x|(\ .YP.Y rb X /DU/TI7 user_transaction /-[7t/U/ **-[7 RASER T0V1, 4/I7/(@f0D\ ** Validate that the publisher is a valid server */ select @publisher_srvid = srvid from master..aesaa ia .X0/@7 grrevL/ /-[7 P/  / 4/7/dV0H0X VEX 4.hA6.h(@Q0D\URN (1) END /* ** Validate that the subscriber is a valid server */ select @subscriber_srvid = sP/D c/(AQO8+vC9d70sp_MSenumdeletesmetadatat/M/;0&QO8$$;@pubidT/O/6QO8@pubidx/N/?0&QO888 ?@maxrows@X/O/ 6QO8 @maxrowsx/O/?0&QO8?@genlistX/O/ 6QO8 @genlist|/P/C0&QO888 C@tablenick\/ R/$6QO8$@tablenick@x/ Q/ ?0&QO8$$?@rowguidX/ R/  6QO8 @rowguidP/  /QO8_ / QO8/U /b0*QO8P 7 bsp_MSenumdeletesmetadatax/Y@>6QO8>sp_MSenumdeletesmetadatantD/Z/  QO8t/ )h;0QO8; CREATE PROCEDURE sp_MSenumdeletesmetadata (@pubid uniqueidentifier, @maxrows int, @genlist varchar(1000), @tablenick int, @rowguid uniqueidentifier) as declare @tnstring nvarchar(12) declare @rgstring nvarchar(38) declare @pubidstr nvarchar(38) /* ** To public. *@ if (@genlist is null) begin RAISERROR(14043, 16, -1, '@genlist') return (1) end if (not exists(select * from sysobjects where name = 'MSmerge_contents')) begin RAISERROR(20054 , 16, -1) return (1) end set @pubidstr = '''' + convert(nchar(36), @pubid) + '''' if (@tablenick = 0) begin set rowcount @maxrows execute ('select tablenick, rowguid, generation, lineage, ts.type from MSmerge_tombstone ts, sysmergearticles sm where generation in (' + @genlist @ ') and sm.pubid = ' + @pubidstr + ' and ts.tablenick = sm.nickname order by tablenick desc, rowguid asc' ) end else begin set rowcount @maxrows set @tnstring = convert(nchar, @tablenick) set @rgstring = '''' + convert(nchar(36), @rowguid) + '''' execute ('select tablenick, rowguid, generation, lineage, ts.type from MSmerge_tombstone ts, sysmergearticles sm where generation in (' + @genlist + ') and ((tablenick = ' + @tnstring + ' and rowgui@ > ' + @rgstring + ') or tablenick < ' + @tnstring + ') and sm.pubid = ' + @pubidstr + ' and ts.tablenick = sm.nickname order by tablenick desc, rowguid asc' ) end IF @@ERROR <>0 begin return (1) end return (0) 'P/  /P/ /P/ / PH /4/7/́CV0L \ T@ x(X4\_ucount, conflicts_dcount ) exec ( @cmd ) fetch hCdcount into @aname end close hCdcount deallocate hCdcount -- get update counts if ( @publication_name = '%' ) declare hCucount CURSOR LOCAL FAST_FORWARD fast_forward for select distinct a.name, a.conflict_table from sysmergepublications p in/d+//X/DU /T*7 user_transaction /QO8t/U / **QO8conlic b dll 4/*7/(@f0D\ hCucount into @aname, @conflict_table while ( @@fetch_status <> -1 ) begin select @cmd = 'select ''' + @aname + ''', X0/@u7 grrevblL/ /QO8 P/  / 4/u7/dV0V0X @cmd ) fetch hCucount into @aname, @conflict_table end close hCucount deallocate hCucount update #conflict_list set conflicts_ucount = isnull( ul.conflicts_ucount, 0 ) from #conflict_list P2 /D c/(A+vC9d7:d7.sp_MSenumpartialdeletes x/e)B ?0&+vC988 ?@maxrows@X/d/  6+vC9 @maxrows|/e/C0&+vC988 C@tabl@enick+\/e/$6+vC9$@tablenickx/e/?0&+vC9$$?@rowguid X/e/ 6+vC9 @rowguid/e/O0&+vC9O@tablenotbelongseh/ g/06+vC9@0@tablenotbelongsP/  / +vC9nn / +vC9/ U/`0*+vC9P 7 `sp_MSenumpartialdeletest/ Y/<6+vC9<sp_MSenumpartialdeletesD/Z/ +vC9/@))r0+vC9r CREATE PROCEDURE sp_MSenumpartialdeletes (@maxrows int, @tablenick int, @rowguid uniqueidentifier, @tablenotbelongs nvarchar(255)) as declare @tnstring nvarchar(12) declare @rgstring nvarchar(38) /* ** To public. */ if (not exists(select * from sysobjects where name = 'MSmerge_contents')) begin RAISERROR(20054 , 16, -1) return (1) end if (@tablenick < 1) begin set rowcount @maxrows execute ('sele@t tablenick, rowguid, COALESCE (generation, 0), lineage, type from ' + @tablenotbelongs + ' order by tablenick desc, rowguid asc' ) end else begin set rowcount @maxrows set @tnstring = convert(nchar, @tablenick) set @rgstring = '''' + convert(nchar(36), @rowguid) + '''' execute ('select tablenick, rowguid, COALESCE (generation, 0), lineage, type from ' + @tablenotbelongs + ' where ((tablenick = ' + @tnstring + ' and rowguid > ' + @rgstring + ') or tablen@ck < ' + @tnstring + ') order by tablenick desc, rowguid asc' ) end IF @@ERROR <>0 begin return (1) end return (0) sP/  /P/ /P/ / P/ /4/7/HCV0 4 0x(8h 8\6 grrevsuL.y .i[ P.y  .j 4.y6.ydV0N0X.srvid = @publisher_srvid and subs2.db_name = @publisher_db and subs1.pubid = subs2.subid and subs2.pubid = pubs.pubid and pubs.name = @publication icX/DU/ T 7 user_transaction /+vC9t/U/ **+vC9G@ `lbio4/ 7/(@f0D\(@publicationP.z# .jA%, -P.X0/@V7 grrevL/  /+vC9 P/  / 4/V7/dV0h0X .z .z S+.xj0*P N6 jsp_helpmergearticleconflicts P0/D c/(Ad7:+;T7 sp_MSenumchangesx/e/ ?0&d7:88 ?@maxrowsrX// 6d7: @maxrowsx/e/?0&d7:?@genlist X/@/ 6d7: @genlist|/e/C0&d7:88 C@tablenickc\//$6d7:$@tablenickx/e/?0&d7:$$?@rowguidVX/ / 6d7: @rowguidt/@ e/ ;0&d7:$$;@pubid.T/ / 6d7:@pubidP/  )Yd7:@]y P/  / d7: P/ /d7:onfP/ /d7:jec@ /d7:/U/R0*d7:P 7 Rsp_MSenumchangescth/Y/.6d7:.sp_MSenumchangesULD/Z/ d7:0/)/0d7: CREATE PROCEDURE sp_MSenumchanges (@maxrows int, @genlist varchar(1000), @tablenick int@ @rowguid uniqueidentifier, @pubid uniqueidentifier = NULL) as declare @tnstring nvarchar(12) declare @rgstring nvarchar(38) declare @tablename sysname declare @retcode smallint declare @ownername sysname declare @procname nvarchar(258) /* ** To public. */ if (@tablenick is null) begin RAISERROR(14043, 16, -1, '@tablenick') return (1) end exec @retcode = dbo.sp_MStablenamefromnick @tablenick, @tablename out, @pubid if @@ERROR<>0 or @retcode<>0 begin retur@ (1) end if (@genlist is null) begin RAISERROR(14043, 16, -1, '@genlist') return (1) end if (not exists(select * from sysobjects where name = 'MSmerge_contents')) begin RAISERROR(20054 , 16, -1) return (1) end create table #cont (tablenick int NOT NULL, rowguid uniqueidentifier NOT NULL, generation int NULL, lineage varbinary(249) NULL ,colv1 varbinary(2048) NULL) set rowcount @maxrows set @tnstring = convert(nchar, @tablenick) set @rgstring = '''' + convert(nchar@36), @rowguid) + '''' execute ('insert into #cont select tablenick, rowguid, generation, lineage, colv1 from MSmerge_contents where generation in (' + @genlist + ') and tablenick = ' + @tnstring + ' and rowguid > ' + @rgstring + ' order by rowguid' ) if @@ERROR <>0 begin return (1) end select @ownername = user_name(uid) from sysobjects where id = object_id(@tablename) select @procname = select_proc from sysmergearticles where nickname=@tablenic@ and pubid = @pubid exec @retcode = @procname @type=2 IF @@ERROR<>0 or @retcode<>0 RETURN (1) drop table #cont return (0) P/  /P/ /P/ / P/ /4/7/́CV0xHX `l(P(\S+.z T6 user_transaction .t.S+. **R<>0 j lco4.6.(@Q0D\NSACTION END /* ** Return succe(k(n,X/DU/T77 user_transaction /d7:t/U/ **d7:publ RtT`4/77/(@f0D\(@publication.2.M0&(X0/@7 grrevL/ /d7: P/  / 4/7/dV0X0XeconflictrowsPH//6SplitNextD.  .Y %/@L. !P/D c/(A+;<d7.sp_MSenumpartialchangesx/e&/ ?0&+;88 ?@maxrowsX/ /  6+; @maxrows|/e'/C0&+;C@temp@_cont\/!/$6+;$@temp_cont|/e(/C0&+;88 C@tablenick\/!/$6+;$@tablenickx/e)/?0&+;$$?@rowguidX/ !/ 6+; @rowguidt/ e*/ ;0&+;$$;@pubidT/ !/ 6+;@pubidP/ 5 /+;@]yeP/ 5 / +;uP/6 /+;"P/6 /@+;`f /+;/U"/`0*+;P 7 `sp_MSenumpartialchangest/Y/<6+;<sp_MSenumpartialchangesD/Z/ +;/)B0+; CREATE PROCEDURE sp_MSenumpartialchanges @ (@maxrows int, @temp_cont sysname, @tablenick int, @rowguid uniqueidentifier, @pubid uniqueidentifier = NULL) as declare @retcode smallint declare @tnstring nvarchar(12) declare @rgstring nvarchar(38) -- Owner qualified declare @tablename nvarchar(266) declare @procname nvarchar(258) declare @ownername sysname /* ** To public. */ if (@tablenick is null) begin RAISERROR(14043, 16, -1, '@tablenick') return (1) end exec @retcode = dbo.sp_MStablenamefromnick @@ablenick, @tablename out, @pubid if @@ERROR<>0 or @retcode<>0 begin return (1) end if (not exists(select * from sysobjects where name = 'MSmerge_contents')) begin RAISERROR(20054 , 16, -1) return (1) end set rowcount @maxrows set @tnstring = convert(nchar, @tablenick) set @rgstring = '''' + convert(nchar(36), @rowguid) + '''' create table #cont (tablenick int NOT NULL, rowguid uniqueidentifier NOT NULL, generation int NULL, lineage varbinary(249) NULL ,colv1 varbin@ry(2048) NULL) execute ('insert into #cont select tablenick, rowguid, generation, lineage, colv from ' + @temp_cont + ' where tablenick = ' + @tnstring + ' and rowguid > ' + @rgstring + ' order by rowguid') if @@ERROR<>0 begin return (1) end /* execute ('select c.tablenick, c.rowguid, c.generation, c.lineage, c.colv, t.* from ' + @tablename + ' t, ' + @temp_cont + ' c where (c.tablenick = ' + @tnstring + ' and c.rowguid > ' + @rgstring + ' and @ t.rowguidcol = c.rowguid) order by c.rowguid' ) */ select @ownername = user_name(uid) from sysobjects where id = object_id(@tablename) select @procname = select_proc from sysmergearticles where nickname=@tablenick and pubid = @pubid exec @retcode = @procname @type =3 IF @@ERROR<>0 or @retcode<>0 RETURN (1) drop table #cont return (0) rP/  /P/ /HP/ / P/ /4/7/́CV0dtD8x(@h 8\iv67\4sp_MSdeletecontents<. H. !Hx8x.) @6!@sp_helpmergesubs at @X/DU"/Tc7 user_transaction /+;t/U"/ **+; `b(4/c7/(@f0D\(CREATE PROCEDURE sp_helpmergeconflictrows( @publication sysname = '%', @conflict_table sysnamX0/@7 grrevshL/\ ,+; P/  / 4/7/dV0"0X * from ' select @cmd = @cmd + @conflict_table if @publication <> '%' begin /* ** Parameter Check: @publication. ** Make sure that the publicationP,<>/D c/(A<=\7&sp_MSgetrowmetadata |/eD/ C0&<88 C@tablenick \/>/ $6<$@tablenickx/eE/?0&<$$?@rowg@uid X/>/ 6< @rowguidH/7SplitNextD/ / /@L/e&L/ e/  L/ *< eh'l'/ / @7EKaQWGcSYOSSC?=;IG;9GCIGEK=?G?EM;9==?KG?GK=A?9A?=EE;;9C0&ҕ;E@subscriber0&ҕ;  K@subscriber_db0&ҕ;88  a@subscriber_security_mode0&ҕ;  Q@subscriber_login = 0&ҕ;  W@subscrib@er_password0&ҕ;  G@distributor0&ҕ;88 c@distributor_security_mode0&ҕ;S@distributor_login0&ҕ;Y@distributor_password0&ҕ;$$O@subscription_id0&ҕ;88 S@indepe@ndent_agento0&ҕ;88 S@subscription_typew0&<88 C@tablenick0&<$$?@rowguid0&o4<=@server0&o4< ;@local0&o4< I@duplicate_ok0&T<G@publication@&T<88 ;@found0&i<9@named 0&i=@servericl0&9>#?@optname 0&9>K@show_topologys0&r5=>G@publicationu0&r5=>?@articlea0&r5=>@G@filter_name 0&r5=>ccK@filter_clause 0& DR>88 =@msgnumcmd0& DR>44A@severityom 0& DR>?@msgtext 0& DR>9@langjec0& DR>A@with_log sy0& DR>?@replace 0&?r>@=@dbnamecks0&^?E@rmtsrvnameME(0&^?E@localloginect0&Y1?88 ;@artidb0&Y1?44;@colid 0&Y1?9@type03,0&Y1? C@operationE</ e8/ 7x8L/@/; ҕ;icP/ /4/7/V07// E0&<88 E@generation`/>/&6<&@generationt//90&<00@9@typeT/A/6<@type\x//?0&<?@lineage X/?/ 6< @lineaget//90&<9@colvid T/>/6<@col@t//;0&<$$;@pubidT/A/6<@pubidP/B /<*P/C /<@]yP/C /<R iP/C /<@ /</U)/X0*

'local' begin raiserror(15379,-1,-1,@local) return (1) end -- ERROR IF ALREADY HAVE A LOCAL SERVER NAME if exists (@select * from master.dbo.sysservers where srvid = 0) begin raiserror(15090,-1,-1) return (1) end end -- ADD THE SERVER (CHECKS PERMISSIONS, ETC) execute @retcode = sp_addlinkedserver @server @ if @retcode <> 0 return @retcode -- SET THE SERVER ID IF LOCAL OPTION SPECIFIED if @local = 'local' begin declare @srvid smallint -- UPDATE DEFAULT MAPPING CREATED BY sp_addlinkedserver select @srvid = srvid from master.dbo@.sysservers where srvname = @server update master.dbo.sysxlogins set srvid = 0 where srvid = @srvid update master.dbo.sysservers set srvid = 0, schemadate = getdate() where srvname = @server end -- FOR COMPATIBI@LITY, TURN OFF THE data access SERVER OPTION execute @retcode = sp_serveroption @server, 'data access', 'off' if @retcode <> 0 return @retcode -- FOR COMPATIBILITY: make rpc-s behave as in 6.5 select @statvalue = number from mas@ter..spt_values where name = 'local login mapping' and type = 'A' --SET 'local login mapping', 'off' update master.dbo.sysservers set srvstatus = srvstatus & ~@statvalue, schemadate = getdate() where srvname = @server if @ret@code <> 0 return @retcode -- SUCCESS (MESSAGE ALREADY PRINTED) return (0) -- sp_addserver @0T<} CREATE PROCEDURE sp_helppublication ( @publication sysname = '%', /* The publication name */ @found int = 23456 OUTPUT /* a flag indicate returning row */ ) AS SET NOCOUNT ON /* ** Declarations. @ */ DECLARE @pubid int DECLARE @has_subscription bit DECLARE @retcode int DECLARE @no_row bit DECLARE @publish_bit int SELECT @publish_bit = 1 /* ** Check if the database is published. */ IF NOT EXISTS (SELECT * FROM master..sysdatabases WHERE name = db_name() AND (category & @publish_bit) = @publish_bit) RETURN(0) /* ** Security Check. To public. */ /* ** Initializations. */ @ IF @found = 23456 BEGIN SELECT @no_row=0 END ELSE BEGIN SELECT @no_row=1 END /* ** Parameter Check: @publication. ** Check to make sure that there are some publications ** to display. */ IF @publication IS NULL BEGIN RAISERROR (14043, 16, -1, '@publication') RETURN (1) END IF @publication <> '%' BEGIN EXECUTE @retcode = dbo.sp_validname @publication IF @retcode <> 0 RETURN (1) END IF NOT EXISTS (SELECT * FROM syspublications WHERE name like @publication) BEGIN SELECT @found = 0 RETURN (0) END ELSE BEGIN SELECT @found = 1 IF @no_row <>0 RETURN(0) END SELECT 'pubid' = pubid, 'name' = name, 'restricted' = 0, 'status@ = status, -- using 'task' is for backward compatible 'task' = convert(int, 1), 'replication frequency' = repl_freq, 'synchronization method' = sync_method, 'description' = description, 'immediate_sync' = immediate_sync, 'enabled_for_internet' = enabled_for_internet, 'allow_push' = allow_push, 'allow_pull' = allow_pul@, 'allow_anonymous' = allow_anonymous, 'independent_agent' = independent_agent, 'immediate_sync_ready' = immediate_sync_ready, -- SyncTran 'allow_sync_tran' = allow_sync_tran, 'autogen_sync_procs' = autogen_sync_procs, 'snapshot_jobid' = snapshot_jobid, 'retention' = retention, 'has subscription' = case when EXISTS (select * from syssubscript@ons where artid in (select artid from sysarticles where pubid in (select inside.pubid from syspublications inside where inside.name = outter.name))) then 1 else 0 end FROM syspublications outter WHERE name LIKE @publication ORDER BY name RETURN (0) ct</( /&Px8L/))/~o4<'P/* H /4/#7/#V0<<;;d;Dl(, lx<lD@8`4\ select @cmd = @cmd + @tablenickstr select @cmd = @cmd + ' and rowguid = ''' select @cmd = @cmd + @roil'@ v 0P >/'</"/)0< CREATE PROCEDURE sp_MSgetrowmetadata (@tablenick int, @rowguid uniqueidentifier, @generation int output, @type tinyint output, @lineage varbinary(255) output, @colv varbinary(2048) output, @pubid uniqueidentifier = NULL) as declare @retcode smallint declare @saverr int declare @rc int declare @procname nvarchar(258) declare @ownername sysname /* ** To public@ */ if (@tablenick is null) begin RAISERROR(14043, 16, -1, '@tablenick') return (1) end if (@rowguid is null) begin RAISERROR(14043, 16, -1, '@rowguid') return (1) end if (not exists(select * from sysobjects where name = 'MSmerge_contents')) begin RAISERROR(20054 , 16, -1) return (1) end select @colv = null select @type = type, @generation = generation, @lineage = lineage from MSmerge_tombstone where tablenick = @tablenick and rowguid = @rowguid if@(@lineage is null) begin select @type = 0 select @generation = 0 end if (@type = 0) begin declare @tablename nvarchar(266) exec @retcode = dbo.sp_MStablenamefromnick @tablenick, @tablename out, @pubid if @@ERROR<>0 begin return (1) end select @ownername = user_name(uid) from sysobjects where id = object_id(@tablename) select @procname = select_proc from sysmergearticles where objid = object_id(@tablename) and pubid = @pubid exec @retcode = @procname @type@=4, @rowguid=@rowguid select @saverr = @@ERROR, @rc = @@rowcount if @saverr <>0 return (1) if (@rc = 1) begin select @type = 3 select @type = 2, @generation = generation, @lineage = lineage, @colv = colv1 from MSmerge_contents where tablenick = @tablenick and rowguid = @rowguid end end return (0) P/'  /+P/' /'P/'H /' P/' /'4/7/́CV0DTcute dbo.sp_MStablenickname @owner, @object, @tablenick output if @tablenick IS NULL OR @@ERROR<>0 BEGIN raiserror (20003, 11, -1, @object) RETURN (1) END if @rowguid IS NULL begin raiserror (14027, 11, -1, '@rowguid .X /,DU)/ /TD7 user_transaction /,<t/,U)/, **< XZ4/,D7/,(@f0D\P. .4.6.X0/-@7 grrev L/-\ /< P/-  /' 4/-7/-dV0-0Xibutor, @reserved = 1 EXECUTE dbo.sp_dropmergesubscription @publication = @publication, @subscriber = @subscriber, rP$\'(/.D c/(A=H+>\%7&sp_MSsetrowmetadata|/./C0&=88 C@tablenick\/.Q/$6=$@tablenickx/. /.?0&=$$?@rowg@uidX/.Q/. 6= @rowguid/.!/.E0&=88 E@generation`/.Q/.&6=&@generationdx/."/.?0&=?@lineageX/. R/. 6= @lineaget/. #/. 90&=9@colvT/. Q/. 6=@colvt/. $/. 90&=009@typesT/. V/. 6=@typeP/.U /=˧iP/.@U /.= /.=/.U0/,X0*=P %7 Xsp_MSsetrowmetadatal/.]/46=4sp_MSsetrowmetadataD/.Z/" =H/%7SplitNextD/. @/$/k o@tpuL/.L/./' t L/.)2stch,/./.)0~ <)xpstar.dll 0)=create procedure sp_setnetname --- 1995/12/22 13:07 @server sysname -- server name ,@netname sysname -- new n@t name as -- DISALLOW USER TRANSACTION set implicit_transactions off if @@trancount > 0 begin raiserror(15002,-1,-1,'sp_setnetname') return (1) end -- CHECK PERMISSIONS if not (is_srvrolemember('setupadmin') = 1) begin raiserror(15232,-1,-1) return (1) end -- CHECK SERVER NAME (MUST BE A SQL SERVER!) if not exists (select * from master.dbo.sysservers where srvname = @server and srvproduct = N'S@L Server') begin raiserror(15015,-1,-1,@server) return (1) end -- DO THE UPDATE update master.dbo.sysservers set datasource = @netname, schemadate = getdate() where srvname = @server -- SUCCESS raiserror(15510,-1,-1) return (0) -- sp_setnetname a_t</. /.x8L/.)/*~ <guP/.  /-@4/.%7/.V0X/./.0= CREATE PROCEDURE sp_MSsetrowmetadata (@tablenick int, @rowguid uniqueidentifier, @generation int, @lineage varbinary(255), @colv varbinary(2048), @type tinyint) as declare @@reason nvarchar(255) declare @cvcurrent varbinary(2048) /* ** Check to see if current publication has permission */ declare @retcode int exec @retcode=sp_MSreplcheck_connection @tablenick = @tablenick if @retcode<>0 or @@ERROR<>0 return@ (1) if (@tablenick is null) begin RAISERROR(14043, 16, -1, '@tablenick') return (1) end if (@rowguid is null) begin RAISERROR(14043, 16, -1, '@rowguid') return (1) end if (@generation is null) begin RAISERROR(14043, @16, -1, '@generation') return (1) end if (@lineage is null) begin RAISERROR(14043, 16, -1, '@lineage') return (1) end if (not exists(select * from sysobjects where name = 'MSmerge_contents')) begin RAISERROR(20054 , 16, -1) r@eturn (1) end if (@type = 1 or @type = 5 or @type = 6) begin if @type = 5 begin set @reason = formatmessage(20563) -- Out of partial range set @lineage = 0x00 end else if @type = 6 begin set @reason = formatmessage(20@564) -- Deleted by system end else begin set @reason = formatmessage(20562) -- Deleted by user end -- update or insert MSmerge_tombstone update MSmerge_tombstone set generation = @generation, lineage = @lineage, type = @type, reaso@n = @reason where tablenick = @tablenick and rowguid = @rowguid if (@@rowcount = 0) insert into MSmerge_tombstone (rowguid, tablenick, type, generation, lineage, reason) values (@rowguid, @tablenick, @type, @generation, @lineage, @reason) @ end else begin -- update or insert to MSmerge_contents select @cvcurrent = colv1 from MSmerge_contents where tablenick = @tablenick and rowguid = @rowguid if (datalength(@colv) < datalength(@cvcurrent)) set @colv = @cvcurrent /* If@ filter values have changed, don't change generation */ update MSmerge_contents set generation = @generation, lineage = @lineage, colv1 = @colv where tablenick = @tablenick and rowguid = @rowguid and (partchangegen is null or partchangegen <> g@eneration) and (joinchangegen is null or joinchangegen <> generation) /* If filter values have changed, still update lineage and colv */ if (@@rowcount = 0) update MSmerge_contents set lineage = @lineage, colv1 = @colv where tablenick = @@tablenick and rowguid = @rowguid if (@@rowcount = 0) begin if not exists (select * from MSmerge_contents where tablenick = @tablenick and rowguid = @rowguid) insert into MSmerge_contents (rowguid, tablenick, generation, lineage, colv1) @ values (@rowguid, @tablenick, @generation, @lineage, @colv) delete from MSmerge_tombstone where tablenick = @tablenick and rowguid = @rowguid end end IF @@ERROR<>0 return (1) return (0) ,1)P/.  /.P/. H/. P/.! /.! P/." /."4/.%7/.́CV0&&@&%%H x <  x,\`@L@`4\er sysname, @ret int -- DISALLOW USER TRANSACTION -- set implicit_transactions off if (@@trancount > 0) beQe@X(/BDU0/.hTp7 user_transaction /B=t/BU0/B **=d X Z('d4/Bp7/B(@f0D\wner) = 1) begin raiserror(15000,-1,-1) return (1) end -- ERROR IF ROLE NOT FOUND -- if @uid is nullX0/C@7 grrevERL/C\ /-= P/C  /.# 4/C7/CdV0V0X if exists (select * from sysmembers where groupuid = @uid) begin raiserror(15144,-1,-1) select name = user_name(memberuid) from sysmembers where groupuid = @uid return (1) end P/DD c/.(AH+>O>`Q7*sp_MSinsertgenhistoryelx/D./. ?0&H+>$$?@guidsrcEX/D`/. 6H+> @guidsrcp/D//D70&H+>88 7@genP@D`/D6H+>@gent/D0/D;0&H+>$$;@pubidT/Db/D6H+>@pubidP/Dc /.H+>˧ire P/D c /D H+> NU /D H+>/D /@\0*H+>P Q7 \sp_MSinsertgenhistoryp/D " /86H+>8sp_MSinsertgenhistoryD/D Z/. H+>/D)30H+> CREATE PROCEDURE sp_MSinsertgenhistory (@guidsrc uniqueidentifier, @gen int output, @pubid uniqueidentifier) as declare @dt datetime /* @ ** Check to see if current publication has permission */ declare @retcode int declare @saverr int exec @retcode=sp_MSreplcheck_connection @pubid = @pubid if @retcode<>0 or @@ERROR<>0 return (1) if (@guidsrc is null) begin RAISERROR(14043, 16, -1, '@guidsrc') return (1) end if (not exists(select * from sysobjects where name = 'MSmerge_contents')) begin RAISERROR(20054 , 16, -1) return (1) end /* Check for older in process generation */ if exists (select * @rom MSmerge_genhistory where guidsrc = @guidsrc) begin select @gen = max(generation) from MSmerge_genhistory where guidsrc = @guidsrc return (0) end select @dt = getdate() begin tran insert into MSmerge_genhistory (guidsrc, pubid, guidlocal, generation, nicknames, coldate) select @guidsrc, @pubid, '00000000-0000-0000-0000-000000000000', COALESCE(1 + max(generation), 1), 0x0, @dt from MSmerge_genhistory (updlock) select @saverr = @@error select @gen = generation from MSm@rge_genhistory where guidsrc = @guidsrc if @gen is null begin update MSmerge_genhistory set generation = 1 where guidsrc = @guidsrc set @gen = 1 end if @saverr = 0 begin /* Now put in rows for other publications that share articles with this one */ insert into MSmerge_genhistory (guidsrc, pubid, guidlocal, generation, nicknames, coldate) select distinct @guidsrc, pubid, '00000000-0000-0000-0000-000000000000', @gen, 0x0, @dt from sysmergearticles where pubid <> @pubid a@d artid in (select artid from sysmergearticles where pubid = @pubid) select @saverr = @@error end commit tran if (@saverr <> 0) begin RAISERROR(15001, 16, -1, 'MSmerge_genhistory') return (1) end return (0) aP/D  /CP/D /DP/D /D P/D H/D4/DQ7/D́CV04 D hdL4\user_transaction .EYH$t.SR. **EYH$P \^4.6.(@Q0D\P X.P4.IX6.Inef /X/LD/D T7 user_transaction /LH+>t/L/L **H+> \u^ 4/L7/L(@f0D\ int NOT NULL, centralized_conflicts int EFo@bien mrss_ Tc0 Esrti X0/M@7 grrev<%L/M\ /CH+> P/M  /D 4/M7/MdV0 0Xation`.q.(6~}<%(@publicationP. . ~}<% atP.Pd/ND c/D(AO>s?`2 7*sp_MSupdategenhistoryx/N?/D?0&O>$$?@guidsrcX/Nq/D 6O> @guidsrct/N@/N;0&O>$$;@pubid@T/Nr/N6O>@pubidp/NA/N70&O>88 7@genP/Nq/N6O>@gen|/NB/NA0&O>88 A@art_nick\/N q/N"6O>"@art_nickuP/N @ /D O>˧iP/N  /N O>t d /N O>/N  /L\0*O>P 2 7 \sp_MSupdategenhistoryp/N]//.86O>8sp_MSupdategenhistoryD/NZ/D O>/N@)40O> CREATE PROCEDURE sp_MSupdategenhistory (@guidsrc uniqueidentifier, @pubid uniqueidentifier, @gen int, @art_nick int = NULL) as declare @guidlocal uniqueidentifier declare @dt datetime /* ** Check to see if current publication has permission */ declare @retcode int exec @retcode=sp_MSreplcheck_connection @pubid = @pubid if @retcode<>0 or @@ERROR<>0 return (1) if (@guidsrc is null) begin RAISERROR(14043, 16,@-1, '@guidsrc') return (1) end if (not exists(select * from sysobjects where name = 'MSmerge_contents')) begin RAISERROR(20054 , 16, -1) return (1) end select @dt = getdate() if @art_nick = 0 set @art_nick = NULL set @guidlocal = newid() begin tran if exists (select * from MSmerge_genhistory where guidsrc = @guidsrc and generation < @gen) begin update MSmerge_contents set generation = @gen where generation in (select generation from MSmerge_genhistory where @uidsrc = @guidsrc and generation < @gen) if @@ERROR <> 0 goto FAILURE update MSmerge_tombstone set generation = @gen where generation in (select generation from MSmerge_genhistory where guidsrc = @guidsrc and generation < @gen) if @@ERROR <> 0 goto FAILURE delete from MSmerge_genhistory where guidsrc = @guidsrc and generation < @gen if @@ERROR <> 0 goto FAILURE end if exists (select * from MSmerge_genhistory where guidsrc = @guidsrc) update MSmerge_genhistory set guidlocal = @gui@local, art_nick = @art_nick where guidsrc = @guidsrc else insert into MSmerge_genhistory (guidsrc, guidlocal, generation, art_nick, nicknames, coldate) values (@guidsrc, @guidlocal, @gen, @art_nick, 0x0, @dt) commit IF @@ERROR<>0 return (1) return (0) FAILURE: /* UNDONE : This code is specific to 6.X nested transaction semantics */ if @@TRANCOUNT = 1 ROLLBACK TRANSACTION else COMMIT TRANSACTION RETURN 1 t(P/N  /MHP/N /NP/N /N P/N /N4/N2 7/ŃCV0d @<T4\(@constraint_name is null or c_obj.name = @constraint_name) and (@constraint_catalog is null or @constraint_catalog = db_name()) and (@constradg X/VD /NT} 7 user_transaction /VO>t/V /V **O> < \^4/V} 7/V(@f0D\.q% NP.  .X0/W@ 7 grrevL/W\ /MO> P/W  /N 4/W 7/WdV0'0Xcode int declare @objid int declare @owner sysname declare @table sysname set nocount on select @pubid = pubid from sysmergepublications where name = @publication and UPPER(puPR /XD c/N(As?@` 7*sp_MSenumschemachange t/X / ;0&s?$$;@pubiduT/X/N 6s?@pubid/X /XK0&s?88 K@schemavers@ionjd/X/X,6s?,@schemaversionP/X /N s?min /Xs?/X/V\0*s?P  7 \sp_MSenumschemachangep/X Y"/!86s?8sp_MSenumschemachangeD/X Z@/N s?/X $ "_0s?_ CREATE PROCEDURE sp_MSenumschemachange( @pubid uniqueidentifier, @schemaversion int ) as /* ** To public */ if (@schemaversion is null) begin RAISERROR(14043, 16, -1, '@schemaversion') return (1) end if (not exists(select * from sysobjects where name = 'MSmerge_contents')) begin RAISERROR(20054 , 16, -1) return (1) end select pubid, artid, s@hemaversion, schemaguid, schematype, schematext from sysmergeschemachange where schemaversion > @schemaversion and pubid = @pubid order by schemaversion return (0) P/X  /WP/X /X P/X /X P/X /X4HX 7/X́CV0\ $pl0\evL. .~}<% P.  . 4.V6.dV0"0X XfZ th4.`6.(@Q0D\er than sampling @norecompute CHAR(12)= 'NO' -- Optional 'NORECOMPUTE' text - if present, then statistics --/cX /]D/X T^ 7 user_transaction /]s?t/]/] **s?stri \o^4/]^ 7/](@f0D\(@distributorP.aG (Lф5W`mbe .aX0/^@ 7 grrevL/^\ /Ws? P/^  /X 4/^ 7/^dV0 0XZ.x ф5Hb/6SplitNextD.  b.x/ DE@LARL. bP /_D c/X(A@,Ad? 7.sp_MSupdateschemachanget/_!/X;0&@$$;@pubidsT/_/X6@@pubidt/_"/_;0&@$$;@artidLT@_/_6@@artid/_#/_K0&@88 K@schemaversionRd/_/_,6@,@schemaversion/_$/_E0&@$$E@schemaguidMA,`/_ /_&6@&@schemaguid/_ %/_ E0&@88 E@schematypee >`/_ /_ &6@&@schematype/_ &/_ E0&@E@schematext`/_ /_ &6@&@schematextP/_ /@@˧i P/_ /_@ /_@/_/]`0*@P ? 7 `sp_MSupdateschemachanget/_]0/N<6@<sp_MSupdateschemachangeD/_Z/X  @(/_@)Y0@ CREATE PROCEDURE sp_MSupdateschemachange( @pubid uniqueidentifier, @artid uniqueidentifier = NULL, /* Can be NULL for directory commands */ @schemaversion int, @schemaguid uniqueidentifier, @schematype int, @schematext nvarchar(2000) ) as /* ** Check to see if current publication has permission */ declare @retcode int exec @retcode=sp_MSreplcheck_connection @pubid = @pubid if @retcode<>0 or @@ERROR<>0 return (1) @ /* Parameter validation */ if (@schemaversion is null) begin RAISERROR(14043, 16, -1, '@schemaversion') return (1) end if (not exists(select * from sysobjects where name = 'MSmerge_contents')) begin RAISERROR(20054 , 16, -1) return (1) end update sysmergeschemachange set schematext = @schematext, schematype = @schematype where pubid = @pubid and artid = @artid and schemaguid = @schemaguid if @@error <> 0 begin RAISERROR(20054 , 16, -1) return (1) end H return (0) P/_  /^P/_ /_P/_ /_ P/_ /_4/_? 7/_́CV0P `  0x(x8P4\e sp_MSmakeinsertproc if exists (select * from sysobjects X@/X/fD/_T 7 user_transaction /f@t/f/f **@ an na `pbsch4/f 7/f(@f0D\ists (select * from sysobjects where type = 'P' and name = 'sp_MSaddinitialarticle') drop procedure sp_MSaddinitialartX0/g@ 7 grrev nL/g\ /^@ P/g  /_ 4/g 7/gdV00Xticles if exists (select * from sysobjects where type = 'P' and name = 'sp_MSdroparticletombstones') drop procedure sp_MSdroparticletombstones if exists (select * from sysobjects wheP\/hD c/_(A,AeBhk 72sp_MSadd_mergereplcommands'/h2/_ G0&,AG@publicationc`/h/_(6,A(@publicationx/h3/h?0&,A@?@articlesX/h/h 6,A @article/h4/hE0&,A88 E@schematypeMSd`/h/h&6,A&@schematypeSg/h5/hE0&,AE@schematext_MS`/h /h@&6,A&@schematext* P/h  *,Ae dP/h  /h ,AW` whP/h  /h ,A B7getP/h  /h ,A@ /h,A/h /fd0*,AP p 7 ds@_MSadd_mergereplcommandx/h!,/@6,A@sp_MSadd_mergereplcommandD/hZ/_ ,A/h)*0,A /* Add the replication command to the database - Used by snapshot */ CREATE PROCEDURE sp_MSadd_mergereplcommand ( @publication sysname, @article sysname = NULL, @schematype int, @sche@atext nvarchar(2000) ) AS declare @schemaguid uniqueidentifier declare @schemaversion int declare @retcode int declare @pubid uniqueidentifier declare @artid uniqueidentifier /* ** Publish permission check */ exec @retcode=sp_MSreplcheck_publish if @retcode<>0 or @@ERROR<>0 return (1) if @publication IS NULL BEGIN RAISERROR (14003, 16, -1) RETURN (1) END select @pubid = pubid FROM sysmergepublications WHERE name@= @publication and UPPER(publisher)=UPPER(@@SERVERNAME) and publisher_db=db_name() select @artid = artid FROM sysmergearticles WHERE name = @article /* ** For certain system tables that are bcped out such as MSmerge_contents ** and MSmerge_tombstone use the article name as sysobjects.name and get ** sysobjects.id as the artid */ if (@artid IS NULL) AND (@schematype <> 7) begin declare @binguid binary(16) set @binguid = OBJECT_ID(@article) set @artid = conver@(uniqueidentifier, @binguid) end if exists (select * from sysmergeschemachange where pubid = @pubid AND artid = @artid AND (schematype = @schematype or @schematype in (3,4) and schematype in (3,4)) ) begin /* Select the existing schema guid */ select @schemaversion = schemaversion, @schemaguid = schemaguid from sysmergeschemachange where pubid = @pubid AND artid = @artid AND (schematype = @schematype or @schematype in (3,4) and schematype in (3,4)) /* @or directory commands, delete the previous directory before the update */ if (@schematype = 7) begin declare @dir nvarchar(255) declare @local_path nvarchar(255) declare @delcmd nvarchar(255) declare @distributor sysname declare @distproc nvarchar(255) /* ** Get distribution server information for remote RPC call. */ EXEC @retcode = dbo.sp_helpdistributor @rpcsrvname = @distributor OUTPUT IF @@ERROR <> 0 OR @retcod@ <> 0 BEGIN RAISERROR (14071, 16, -1) RETURN (1) END select @dir = schematext from sysmergeschemachange where schemaversion = @schemaversion /* ** We have to convert UNC to drive, otherwise will get 'Access denied' error in xp_cmdshell */ EXEC @retcode = master.dbo.sp_MSunc_to_drive @unc_path = @dir, @local_server = @distributor, @local_path = @local_path OUTPUT if @retcode<>0 or @@ERROR<>0 r@turn (1) /* ** Delete publication directory in the distributor machine. */ SET @distproc = RTRIM(@distributor) + '.master..xp_cmdshell' SET @delcmd = 'rmdir /S /Q ' + @local_path EXECUTE @distproc @delcmd, NO_OUTPUT if @@ERROR<>0 return (1) end /* ** Update the schema change version */ exec @retcode = dbo.sp_MSupdateschemachange @pubid, @artid, @schemaversion, @schemaguid, @schematype, @schematext if @@e@ror <> 0 or @retcode <> 0 begin RAISERROR(20054 , 16, -1) return (1) end end else begin /* Insert the schema change */ select @schemaversion = schemaversion from sysmergeschemachange if (@schemaversion is NULL) set @schemaversion = 1 else select @schemaversion = 1 + max(schemaversion) from sysmergeschemachange /* generate a new schema guid */ set @schemaguid = newid() exec @retcode = dbo.sp_MSinsertschemachange @pubid, @artid, @schema@ersion, @schemaguid, @schematype, @schematext if @@error <> 0 or @retcode <> 0 begin RAISERROR(20054 , 16, -1) return (1) end end return (0) P/h  /gP/h /hP/h /h P/h /h4/Hp 7/h́CV0X0t$4TtD\ drop procedure sp_MSsetupbelongs if exists (select * from sysobjects where type = 'P' and name = 'sp_MSexpandbelongs') drop procedure sp_MSexpandbelongs if exists (select * from sysobjects where type = 'P' and name = 'sp_MSexpandnotbelongs') drop procedure sp_MSexpandnotbelongs if exists (select * from sysobjects where type = 'P' and name = 'sp_hvreeFt mpX/uD /hprT 7 user_transaction /u,At/u /u **,Aproedu dSfte 4/u 7/u(@f0D\ and name = 'sp_MSdeletepushagent') drop procedure sp_MSdeletepushagent if exists (select * from sysobjects X0/v@ 7 grrevskL/v\ /g,A P/v  /h 4/v 7/vdV0 0Xe = 'sp_MScheckexistsgeneration') drop procedure sp_MScheckexistsgeneration if exists (select * from sysobjects where type = 'P' and name = 'sp_MSenumreplicas') drop procedure sp_MSenumreP$/wD c/h(AeBC\  7&sp_MSsetreplicainfom |/w F/h C0&eBC@publishere\/w r*$6eB$@publisher/w G/wI0&eBI@publ@isher_dbetad/w r/w*6eB*@publisher_dbpe/w H/wG0&eBG@publication `/w r/w(6eB(@publication/w I/wO0&eB88 O@datasource_typegh/w  r@/w06eB0@datasource_type/w  J/w G0&eBG@server_name'`/w  r/w (6eB(@server_namex/w  K/w ?0&eB?@db_namenX/w  r/w  6eB @db_name/@ L/w O0&eBO@datasource_pathMh/w r/w06eB0@datasource_path|/w M/wA0&eB88 A@nicknamect \/w r/w"6eB"@nicknamero/w N/wK0&eB@8  K@schemaversion d/w r /w,6eB ,@schemaversiont/w O/w;0&eB$$  ;@subidT/w r /w6eB @subidP/w  /heB˧i : P/w  /weB@8bmP/w  /weB(TP/w  /weB(n /w eB/w '/uX0*eBP  7 Xsp_MSsetreplicainfol/w ]/_46eB4sp_MSsetreplicainfoD/w Z/h@ eB /w )\ 0eB CREATE PROCEDURE sp_MSsetreplicainfo (@publisher sysname, @publisher_db sysname, @publication sysname, @datasource_type int = 0, /* 0 = SQL Server, 1 = DSN, 2 = Jet */ @server_name sysname = NULL, /* Server Name */ @db_name sysname = NULL, /* Database Name */ @datasource_path nvarchar(255) = NULL,/* Datasource path - JET MDB file path etc */ @nickname int = NULL, @schemaversio@ int = NULL, @subid uniqueidentifier = NULL) as declare @pubid uniqueidentifier declare @repid uniqueidentifier declare @srvid int declare @retcode int /* ** NOTE -- WORKAROUND ODBC PROBLEM */ select @publisher_db = RTRIM(@publisher_db) select @db_name = RTRIM(@db_name) /* ** Subscriber permission check */ if UPPER(@@servername) = UPPER(@publisher) and db_name() = @publisher_db begin exec @retcode=sp_MSreplcheck_connection @publication = @publication @f @retcode<>0 or @@ERROR<>0 return (1) end else begin exec @retcode=sp_MSreplcheck_subscribe if @retcode<>0 or @@ERROR<>0 return (1) end /* ** Parameter Check: @publication. ** Make sure that the publication exists. */ if (@publication is null) begin RAISERROR(14043, 16, -1, '@publication') return (1) end if (@server_name is NULL) SET @server_name = @@SERVERNAME if (@db_name is NULL) set @db_name = db_name() SELECT @srvid = srvid FROM @aster..sysservers WHERE UPPER(srvname) = UPPER(@server_name) IF @@ERROR <> 0 or @srvid IS NULL BEGIN RAISERROR(20021, 16, -1) RETURN (1) END select @pubid = pubid from sysmergepublications where name = @publication and UPPER(publisher)=UPPER(@publisher) and publisher_db=@publisher_db if (@pubid is null) begin RAISERROR (20026, 11, -1, @publication) return (1) end if (@datasource_type = 0) begin SELECT @repid = subid FROM sysmergesubsc@iptions WHERE srvid = @srvid and db_name = @db_name and pubid = @pubid END ELSE BEGIN SELECT @repid = subid FROM sysmergesubscriptions WHERE datasource_path = @datasource_path and pubid = @pubid END if @repid is NULL begin RAISERROR(20021, 16, -1) return (1) end if @schemaversion is not null begin update MSmerge_replinfo set schemaversion = @schemaversion where repid = @repid if @@error <> 0 begin RAISERROR(20054 , 16, -1) return (1) @ end end if @subid is not null and @subid <> @repid begin /* Fix the repid for pull subscribers before we copy around global replica rows */ update MSmerge_replinfo set repid = @subid where repid = @repid if @@error <> 0 begin RAISERROR(20054 , 16, -1) return (1) end update sysmergesubscriptions set subid = @subid where subid = @repid if @@error <> 0 begin RAISERROR(20054 , 16, -1) return (1) end end if @nickname IS NOT NULL @ begin /* If this nickname isn't already assigned, reset it */ if exists (select * from MSmerge_replinfo, sysmergesubscriptions where replnickname = @nickname and repid = subid and (srvid <> @srvid or db_name <> @db_name)) return (0) update MSmerge_replinfo set replnickname = @nickname where repid = @repid if @@error <> 0 begin RAISERROR(20054 , 16, -1) return (1) end end return (0) iP/w   /vHP/w  /w P/w!  /w! P/w"  /w" 4/w  7/ẃCV0 l ` `  p  Dd(HXx4\/R0*)(P 6 Rsp_MScreater rmin8wX/D'/wT  7 user_transaction / eBt/ '/ **eBtnae s X Z@pn4/  7/(@f0D\identifier declare @guidstr varchar(40) declare @retcode smallint /* ** To public. */ set @guid = newid() X0/@ -7 grrev(1L/ \# /veB P/   /w# 4/ -7/dV0X0Xn (1) end exec ('create table ' + @tempname + ' (tablenick int NOT NULL, rowguid uniqueidentifier ROWGUIDCOL default newid() not null, errcode int NOT NULL, errtext nvarchar(255) NULL, type tinyint NOP /D c/w(AC(D` 7*sp_MSsetreplicastatuse t/ )*;0&C$$;@subidnT/ r5/w6C@subid/ */I0&C88 I@status_val@ue ud/ r5/*6C*@status_valueP/ . /wC˧i / C/ ./\0*CP 7 \sp_MSsetreplicastatusp/  ]/w86C8sp_MSsetreplicastatusD/  Z@/w CH /7SplitNextDx87GrowFileT/ c+ 0??ACGKOS]gq{ذz_# /00??ACGKOS]gq{ذz_# /Hl$pl0\u6 grrevsL/& /)( P/&  / 4/&u6/&dV0I0X@join_nickname is NULL begin raiserror (20001, 11, -1, @article, @publication) XN/4/ 7/ Ab )2*P6sp_MSdropretryt/' $5 ;0&b );@tname T/'$/6b )@tnamet/' /';0&b );@pname T/'P/8/  / V0L/ /./D/ //e@r8/ .x8L/ .L/ *<H.L/ .*S ro (@ /)90 C)xpstar.dlltab07C9create proc sp_fulltext_database @action varchar(20) -- 'enable' | 'disable' as declare @ftcatid smallint, @path nvarchar(260), @objid int, @dbid smallint -- VALIDATE PARAMS@ -- if @action is null OR @action not in ('enable','disable') begin raiserror(15600,-1,-1,'sp_fulltext_database') return 1 end -- DISALLOW USER TRANSACTION -- set implicit_transactions off if @@trancount > 0 begin@ raiserror(15002,-1,-1,'sp_fulltext_database') return 1 end -- CHECK PERMISSIONS (must be a dbowner) -- if (is_member('db_owner') = 0) begin raiserror(15000,-1,-1) return 1 end -- CLEAR SYSDATABA@SES BIT AND PROPAGATE W/ CHECKPOINT (for both enable & disable) -- select @dbid = db_id() update master.dbo.sysdatabases set status2 = status2 & ~536870912 where dbid = @dbid checkpoint -- DROP ALL CATALOGS WITH THIS DATABASE (for both enable/dis@able) -- DBCC CALLFULLTEXT ( 7, @dbid ) -- FTDropAllCatalogs ( "@dbid" ) if @@error <> 0 return 1 if @action = 'enable' begin -- CREATE CATALOGS -- declare ftcat_crs cursor static local for select ftcatid, path from sysfulltextcatalogs @ open ftcat_crs fetch ftcat_crs into @ftcatid, @path while @@fetch_status >= 0 begin DBCC CALLFULLTEXT ( 1, @ftcatid, @path ) -- FTCreateCatalog( @ftcatid, @path ) if @@error <> 0 return 1 fetch ftcat_crs into @ftcatid, @path @end deallocate ftcat_crs -- ACTIVATE TABLES/URLs -- declare ftind_crs cursor static local for select ftcatid, id from sysobjects where ObjectProperty(id, 'TableHasActiveFulltextIndex') = 1 open ftind_crs fetch ftind_crs into @ftcatid@, @objid while @@fetch_status >= 0 begin DBCC CALLFULLTEXT ( 5, @ftcatid, @objid ) -- FTAddURL( @ftcatid, db_id(), @objid ) if @@error <> 0 return 1 fetch ftind_crs into @ftcatid, @objid end deallocate ftind_crs -- SET SYS@DATABASES BIT AND PROPAGATE W/ CHECKPOINT -- update master.dbo.sysdatabases set status2 = status2 | 536870912 where dbid = @dbid checkpoint end -- SUCCESS -- return 0 -- sp_fulltext_database </  /lx8L/  )@. CP/   /4/ 7/ V0@/  /0C CREATE PROCEDURE sp_MSsetreplicastatus (@subid uniqueidentifier, @status_value int ) AS /* ** Check to see if current publication has permission */ declare @retcode int exec @retcode=sp_MSreplcheck_connection @repid = @subid if @retco@e<>0 or @@ERROR<>0 return (1) IF EXISTS (select subid from sysmergesubscriptions where subid=@subid) update sysmergesubscriptions set status = @status_value WHERE subid=@subid if @@ERROR<>0 return (1) return (0) &P/   / P/  /P/  / P/  H4/ 7/́CV0,<x(dPV*88 C@tablenick \/39/3$6V*$@tablenickx/3#/3?0&V*$$?@rowguid X/3 9/3 6V* @rowguid /d//X/D./ x8T7 user_transaction /Ct/./ **C \n^ 4/7/(@f0D\ AS set nocount on /* ** Declarations. */ declare @pubid uniqueidentifier X0/@Y7 grrevjiL/\' /C P/  / 4/Y7/dV00X if not exists (select * from sysobjects where name = 'sysmergepublications') BEGIN RAISERROR (20054, 16, -1) RETURN (1) END /* ** Security CheckP>4TV/D c/(A(DMEd70sp_MScreateglobalreplicat/B/;0&(D$$;@pubidT/rN/6(D@pubidt/C/;0&(D$$;@subidT@rO/6(D@subid|/D/C0&(D$$C@partnerid\/rN/$6(D$@partneridH/7SplitNextD/  //@L/ &f@L/ /fL/ f+6 l/ / 4gQca]SO[UMU=A;;C;=9G?EMC=SGUMUggQca]SO[AWA?=;?G?A;??0&C88  g@frequency_recurrence_factor0&C88  Q@frequency_subday0&C88@  c@frequency_subday_intervalB0&C88  a@active_start_time_of_day40&C88 ]@active_end_time_of_day0&C88 S@active_start_date0&C88 O@active_end_date0&C@[@optional@_command_lineM0&CU@distribution_jobidCT0&ChhM@from_auto_syncQN0&ChhU@ignore_distributorUM0&a D=@dbname0&a DA@physname40&(D$$;@pubidC0&(D$$@;@subidC0&(D$$C@partnerid0&p7D;@ftcatM0&p7D=@actionCT0&p7D9@path0&3DG@publication0&3D?@article-0&3DE@subscriber&0&3D@M@destination_dbDZ-0&3DC@sync_type0&3D=@statusNA0&3DS@subscription_type-0&3DG@update_mode0&3D  U@loopback_detection0&3D88  M@frequency_typeID0&@3D88  U@frequency_intervalN_0&3D88  g@frequency_relative_interval0&3D88  g@frequency_recurrence_factorT0&3D88 Q@frequency_subdayNA0&3D88 c@frequency_subday_interval0&3D88 @a@active_start_time_of_dayn0&3D88 ]@active_end_time_of_day0&3D88 S@active_start_date@0&3D88 O@active_end_dateA0&3D@[@optional_command_line0&3DA@reserved/0&3D @W@enabled_for_syncmgr0&ADA@language0&[E ?@tabname0&[E=@action&0&[E;@ftcatA0&[E?@keyname0&:WEG@publication0&:WE?@articl@e0&:WE(A@property0&:WE;@value0&eE?@defnamen0&eE ?@objname</ 5/ 44x8L//C P/ /4/ 7/@ V04//M0&(DM@replica_servereh/rP/.6(D.@replica_servere//E0&(DE@replica_db`/rP/&6(D&@replica_db /@/Q0&(D;;Q@replica_priorityt l/rQ/26(D2@replica_priorityt //O0&(D00O@subscriber_type h/rT/06(D0@subscriber_type//S@&(D88 S@subscription_typel/rU/46(D4@subscription_type//O0&(D88  O@datasource_typeqh/rN/06(D 0@datasource_type//O0&(D @ O@datasource_pathh/rN/06(D 0@datasource_path|/ /A0&(D88  A@nickname*\/!rP/ "6(D "@nicknamef0x/"/!=0&(D88  =@statusetuX/#@rV/"6(D @status|/$/#C0&(D00  C@sync_type\/%rZ/$$6(D $@sync_typeP/&A /(D˧id P/'A /'(D(ed,P/(A /((D@P/)C /)(Do4<\ /*(D4/+5/b0*(DP 7 bsp_MScreateglobalreplicax/,!K/h>6(D>sp_MScreateglobalreplicaD/-Z /  (DH/@7SplitNextD// / /p@bL/034L/13*O4o`L/24*3(b/3/1j0p7Djcreate proc sp_fulltext_catalog @ftcat sysname, -- full-text catalog name @action varchar(20), -- cr@ate | drop | | rebuild | ... @path nvarchar(100) = null -- optional file path for create (max of 100 chars!!!) as -- FULLTEXT MUST BE ACTIVE IN DATABASE -- if DatabaseProperty(db_name(), 'IsFulltextEnabled') = 0 begin raiserror(15601,-1,-1) return 1 end -- VALIDATE PARAMS -- if @action is null OR @action not in ('create','drop','start_full','start_incremental','stop','rebuild') OR @ftcat is null OR len(@ftcat) = 0 OR (@path is not null and @action <> 'create') @begin raiserror(15600,-1,-1,'sp_fulltext_catalog') return 1 end -- DISALLOW USER TRANSACTION -- set implicit_transactions off if @@trancount > 0 begin raiserror(15002,-1,-1,'sp_fulltext_catalog') return 1 end -- CHECK PERMISSIONS (must be a dbowner) -- if (is_member('db_owner') = 0) begin raiserror(15000,-1,-1) return 1 end -- CATALOG MUST EXIST IF NOT CREATING -- declare @ftcatid smallint select @ftcati@ = ftcatid from sysfulltextcatalogs where name = @ftcat if @action <> 'create' and @ftcatid is null begin raiserror(15602,-1,-1,@ftcat) return 1 end if @action = 'create' begin -- ERROR IF ALREADY THERE -- if @ftcatid is not null begin raiserror(15603,-1,-1,@ftcat) return 1 end -- GET CATID AND INSERT ROW -- begin tran if not exists (select * from sysfulltextcatalogs where ftcatid = 5) select @ftcatid = 5 else select @ftcatid = min(ftc@tid+1) from sysfulltextcatalogs where (ftcatid+1) not in (select ftcatid from sysfulltextcatalogs) insert sysfulltextcatalogs values ( @ftcatid, @ftcat, 0, @path ) -- CREATE THE CATALOG (remove row on failure) DBCC CALLFULLTEXT ( 1, @ftcatid, @path ) -- FTCreateCatalog( @ftcat, @path ) if @@error <> 0 begin rollback tran return 1 end commit tran end if @action = 'drop' begin -- CANNOT DROP CATALOG IF USED -- if exists (select * from sysobjects where ftcat@d = @ftcatid) begin raiserror(15604,-1,-1, @ftcat) return 1 end DBCC CALLFULLTEXT ( 2, @ftcatid ) -- FTDropCatalog( @ftcat ) if @@error <> 0 return 1 delete sysfulltextcatalogs where ftcatid = @ftcatid end if @action = 'start_full' begin DBCC CALLFULLTEXT ( 3, @ftcatid, 0 ) -- FTCrawlCatalog( @ftcat, START_FULL ) if @@error <> 0 return 1 end if @action = 'start_incremental' begin DBCC CALLFULLTEXT ( 3, @ftcatid, 1 ) -- FTCrawlCatalog( @ftcat, START_@NCREMENTAL ) if @@error <> 0 return 1 end if @action = 'stop' begin DBCC CALLFULLTEXT ( 4, @ftcatid ) -- FTCrawlCatalog( @ftcat, STOP ) if @@error <> 0 return 1 end if @action = 'rebuild' begin declare @objid int -- RE-CREATE CATALOG (Will first drop) select @path = path from sysfulltextcatalogs where ftcatid = @ftcatid DBCC CALLFULLTEXT ( 1, @ftcatid, @path ) -- FTCreateCatalog( @ftcat, @path ) if @@error <> 0 return 1 -- RE-ACTIVATE TABLES/URLs -@ declare ftind_crs cursor static local for select id from sysobjects where ftcatid = @ftcatid and ObjectProperty(id, 'TableHasActiveFulltextIndex') = 1 open ftind_crs fetch ftind_crs into @objid while @@fetch_status >= 0 begin DBCC CALLFULLTEXT ( 5, @ftcatid, @objid ) -- FTAddURL( @ftcat, db_id(), @objid ) if @@error <> 0 return 1 fetch ftind_crs into @objid end deallocate ftind_crs end -- SUCCESS -- return 0 -- sp_fulltext_catalog @A</4 @3/2nx8L/5) / p7DL P/6  /4//7//V0L/.3/50(D CREATE PROCEDURE sp_MScreateglobalreplica( @pubid uniqueidentifier = NULL, /* Publi@cation ID */ @subid uniqueidentifier, /* Replica ID */ @partnerid uniqueidentifier, /* Partner's Replica ID */ @replica_server sysname, /* Replica server */ @replica_db sysname, /* Replica database */ @replica_priority r@eal, /* Replica priority */ @subscriber_type tinyint = 0, /* Replica's subscriber type - global, hub */ @subscription_type int = 0, /* Replica's subscription type - push or pull */ @datasource_type int = 0, @datasource_path nvarchar(@255) = NULL, @nickname int, /* Replica nickname */ @status int, /* Replica status */ @sync_type tinyint = 2 /* Replica sync type 1 = no sync, 2 = automatic */ ) AS SET NOCOUNT ON /* ** Declarations@. */ DECLARE @replica_srvid int DECLARE @pubnickname int declare @retcode int /* ** Check to see if current publication has permission */ exec @retcode=sp_MSreplcheck_connection @pubid = @pubid if @retcode<>0 or @@ERROR<>0 re@turn (1) /* ** NOTE */ select @replica_db = RTRIM(@replica_db) /* ** Initializations */ SELECT @replica_srvid = srvid from master..sysservers where UPPER(srvname) = UPPER(@replica_server) if @replica_srvid is NULL begin @ EXECUTE @retcode = dbo.sp_addserver @replica_server IF @@error <> 0 OR @retcode <> 0 BEGIN RAISERROR (14042, 16, -1) RETURN (1) END end SELECT @replica_srvid = srvid @from master..sysservers where UPPER(srvname) = UPPER(@replica_server) BEGIN TRAN MScreateglobalreplica /* ** Populate the local copy of sysmergesubscriptions */ if exists (select * from sysmergesubscriptions where subid = @subid and pubid @= @pubid ) begin update sysmergesubscriptions SET subid = @subid, datasource_type = @datasource_type, datasource_path = @datasource_path, srvid = @replica_srvid, db_name = @replica_db, @ pubid = @pubid, status = @status, subscriber_type = @subscriber_type, subscription_type = @subscription_type, priority = @replica_priority, sync_type = @sync_type, login_name = @suser_sname(suser_sid()) where subid = @subid and pubid = @pubid IF @@ERROR <> 0 goto FAILURE end else begin /* ** If attempting to tell the current replica about another replica whose pubid IS NULL @ ** ignore the insert because current replica has more current info. */ if exists (select * from sysmergesubscriptions where subid = @subid and @pubid IS NULL) goto SUCCESS IF EXISTS (SELECT * FROM sysmergesubscriptions WHERE @ srvid = @replica_srvid AND db_name = @replica_db and pubid = @pubid) goto SUCCESS insert sysmergesubscriptions(subid, partnerid, datasource_type, datasource_path, srvid, db_name, pubid, status, subscriber_type, subscription_type, pr@iority, sync_type, login_name) values (@subid, @partnerid, @datasource_type, @datasource_path, @replica_srvid, @replica_db, @pubid, @status, @subscriber_type, @subscription_type, @replica_priority, @sync_type, suser_sname(suser_sid())) IF @@E@RROR <> 0 goto FAILURE end if not exists (select * from MSmerge_replinfo where repid = @subid ) begin INSERT INTO MSmerge_replinfo(repid, replnickname) values (@subid, @nickname) IF @@ERROR <> 0 g@oto FAILURE end SUCCESS: COMMIT TRAN RETURN 0 FAILURE: /* UNDONE : This code is specific to 6.X nested transaction semantics */ if @@TRANCOUNT = 1 ROLLBACK TRANSACTION MScreateglobalreplica else COMMIT TRANSACTION RAISER@ROR (14057, 16, -1) RETURN 1 P/9  /7P/: /:P/; /; P/< /< 4/7/́CV0S4SRRDR22t2(21H#""d" "!!! `  p Hx8HTHl@Lp(P4\P/a /a4/a6/áCV08HxlT(\atalength(@login) select @db_len = datalength(@database) raiserror(916, 16, -1, @login_len, @login, @db_len`-Iiad e(0/XV/D5/,/T:7 user_transaction /(Dt/5/ **(D b d 4/:7/(@f0D\ = @distribdb OUTPUT IF @@error <> 0 BEGIN X0/@7 grrevrL/\* /(D P/  /= 4/7/dV0 0XISERROR (14071, 16, -1) return(1) END SELECT @distproc = RTRIM(@dist_rpcname) + '.P/D c/(AMEIqF`7,sp_MSsetconflictscript/4/%G0&MEG@publication`/ru/&(6ME(@publicationx/5/?0&ME@?@articleX/ru/ 6ME @article/6/O0&MEO@conflict_scripth/rv/06ME0@conflict_scriptt/7/;0&ME;@loginT/ rw/@6ME@login|/ 8/ A0&MEA@password6\/ rx/ "6ME"@passwordP/ c /*MEeDP/ c / MEӞ:P/c /ME0RE /@ME/</^0*MEP 7 ^sp_MSsetconflictscriptart/]/ :6ME:sp_MSsetconflictscriptblD/Z/. ME /*- 0ME /* Add the conflict script pointer to sysmergearticles - Used by snapshot */ CREATE @ROCEDURE sp_MSsetconflictscript ( @publication sysname, @article sysname, @conflict_script nvarchar(255), @login sysname =NULL, @password sysname =NULL ) AS declare @artid uniqueidentifier declare @pubid uniqueidentifier DECLARE @osql_cmd1 nvarchar (255) DECLARE @osql_cmd_full varchar (255) DECLARE @install_path varchar (255) declare @db_name sysname /* ** Check for publish permission. */ declare @retcode int exec @retcode=sp_MSreplcheck_publish if @retcode<>0 or @@ERROR<>0 return (1) select @pubid = pubid from sysmergepublications where name = @publication and UPPER(publisher)=UPPER(@@SERVERNAME) and publisher_db=db_name() if @pubid IS NULL BEGIN RAISERROR (20026, 16, -1, @publication) RETURN (1) END select @artid = artid FROM sysmergearticles WHERE name = @article AND pubid = @pubid if @artid IS NULL BEGIN RAISERROR (20027, 16, -1, @article) RETURN (1) END upd@te sysmergearticles set conflict_script = @conflict_script where artid = @artid if @@ERROR <> 0 return (1) /* if there is already a conflict table, don't run script */ if exists (select * from sysmergearticles where artid = @artid and OBJECT_ID(conflict_table) is null) BEGIN /* Run the script and create the conflict table */ EXECUTE @retcode = master.dbo.xp_regread 'HKEY_LOCAL_MACHINE', 'SOFTWARE\Microsoft\MSSQLServer\Setup', 'SQLPath', @param = @install_path @UTPUT IF @@ERROR<> 0 OR @retcode <> 0 or @install_path is NULL or @install_path='' return (1) IF @login is NULL SELECT @osql_cmd1 = @install_path + '\binn\osql -E ' ELSE -- cannot specify -S w/ -E for local execution, SID does not map due to nofix bug SELECT @osql_cmd1 = @install_path + '\binn\osql -U' + @login + ' -P' + isnull(@password,'') + ' -S' + @@SERVERNAME + ' ' select @osql_cmd1 = @osql_cmd1 + '-l30 -t30 ' set @db_name = db_name() SELECT @osql_cmd_full = @osql_cmd1 + ' -d' + @db_name + ' -b ' + ' -i' + @conflict_script + ' -o' + @install_path + '\install\conflict.out' EXEC @retcode = master..xp_cmdshell @osql_cmd_full IF @@ERROR<> 0 OR @retcode <> 0 return (1) END /* Create the conflict insert proc */ if exists (select * from sysmergearticles where artid = @artid and OBJECT_ID(ins_conflict_proc) is null) BEGIN exec dbo.sp_MSgetconflictinsertproc @artid = @artid, @output = 0 IF @@ERROR<> 0 OR @retcode <> 0 Heturn (1) END return (0) P/  /P/ /P/ / P/ /4/7/́CV0`p \ L$\l<\E0&p r@Oa@PX/D</ wTf7 user_transaction /MEt/</ **MET ^`4/f7/(@f0D\rE /h  / /r //rX0/@7 grrevsL/\. /ME P/  / 4/7/dV0c0X/r I$50 / CREATE PROCEDURE sp_MSgetlastrecgen (@repid uniqueidentifier) as -- To public if (@repid is null) begin RAISERROR(14P /D c/(AIqFG`G7*sp_MSsetconflicttable rx/f/ ?0&IqF?@articleX/t+  6IqF @article/f/M0&IqFM@confli@ct_tableh/t/.6IqF.@conflict_tableP/ /IqF˧ilarP/ /IqF5Iial /IqF/ C/\0*IqFP G7 \sp_MSsetconflicttablep/ ]/@86IqF8sp_MSsetconflicttableD/ [, IqFH/G7SplitNextD/  /0/@L/L/*<OR6,L/*^ / /@/-)0kHF-SQLTrace.dll0u}F)xpstar.dll</ /`x8L/)/6kHFP/  /4/ G7/ V0/ /`0IqF` /* Add the conflict table@pointer to sysmergearticles - Used by reconciler */ CREATE PROCEDURE sp_MSsetconflicttable ( @article sysname, @conflict_table nvarchar(255) ) AS declare @artid uniqueidentifier select @artid = artid FROM sysmergearticles WHERE name = @article if @artid IS NULL BEGIN RAISERROR (20027, 16, -1, @article) RETURN (1) END /* ** Check to see if current publication has permission */ declare @retcode int exec @retcode=sp_MSreplcheck_connect@on @artid = @artid if @retcode<>0 or @@ERROR<>0 return (1) exec @retcode = dbo.sp_MS_marksystemobject @conflict_table if @retcode<>0 or @@ERROR<>0 return (1) update sysmergearticles set conflict_table = @conflict_table where artid = @artid if @@ERROR <> 0 return (1) return (0) P/  /P/ /P/ /H P/ /4/G7/́CV0p 0 d\@<|4\replinfo where repid = @repid return (0) P/x  /wP/x /x P/x /x i X/DC/ x8T7 user_transaction /IqFt/C/ **IqFct_i \^4/7/(@f0D\ject_id|. }d . C0&88 C@cox4X0/@7 grrevL/\2 /IqF P/  / 4/7/dV0!0X XZi4/|?6/|(@f0D\&?@colnameX.  }n.  6P+&(/D c/(AGHl|76sp_MSmakeconflictinsertproc|/f /C0&GC@tablename\/t/$6G$@tablename|/f /C0&G@C@ownername\/t/$6G$@ownername|/f/A0&GA@procname$\/t/"6G"@procname/f/G0&G88 G@basetableid`/ t/@(6G(@basetableidP/  /GP/  / G peP/  / GmP/  / GT1P/ /GP/ /G@P/ /GC@P/ /GcTP/ /GP/ /GP/ /GP/ /G$.}P/@ /G5I /G4/J/h0*GP |7 hsp_MSmakeconflictinsertproc|/"/D D6GDsp_MSmakeconflictinsertprocD/[ /  GH/|7SplitN@xtD/ //@L/L/*^$P L/*@de/ /-)0Ǐ1 select @colname = c.name, @status = c.status, @typename = t.name, @len = c.length, @prec = c.prec, @scale = c.scale from syscolumns c, systypes t where c.id = @id and c.colid = @col@id and c.xusertype = t.xusertype while (@colname is not null) begin if @typename='nvarchar' or @typename='nchar' -- a unit of nchar takes 2 bytes select @len = @len/2 exec @retcode = dbo.sp_MSmaptype @typename out, @len, @prec, @scale if @@ER@ROR<>0 or @retcode<>0 return (1) select @argname = '@p' + rtrim(convert(nchar, @colid)) -- based on colid, add text to appropriate pieces if (COLUMNPROPERTY( @basetableid, @colname, 'IsRowGuidCol') = 1) set @wherepc = ' where rowguidcol = ' + @@argname else if (@colname = 'origin_datasource') select @wherepc = @wherepc + ' and origin_datasource = ' + @argname set @colname = QUOTENAME(@colname) if @arglist is null begin set @arglist = @argname + ' ' + @typename set @collist = @c@olname set @vallist = @argname set @setpc = @colname + ' = ' + @argname end else begin set @arglist = @arglist + ', ' + @argname + ' ' + @typename set @collist = @collist + ', ' + @colname set @vallist = @vallist + ', ' + @argname @ set @setpc = @setpc + ', ' + @colname + ' = ' + @argname end select @colid = min(colid) from syscolumns where id = @id and colid > @colid and iscomputed<>1 set @colname = NULL select @colname = c.name, @status = c.status, @typename = t.name, @@len = c.length, @prec = c.prec, @scale = c.scale from syscolumns c, systypes t where c.id = @id and c.colid = @colid and c.xusertype = t.xusertype end -- now create the procedure select @procname = QUOTENAME(@procname) execute ('Create proc@edure dbo.' + @procname + ' ( ' + @arglist + ') as update ' + @qualname + ' set ' + @setpc + @wherepc + ' if (@@rowcount = 0) insert into ' + @qualname + ' (' + @collist + ') values (' + @vallist + ')') IF @@ERROR <> 0 begin return(1) e@nd execute ('grant execute on ' + @procname + ' to public') exec dbo.sp_MS_marksystemobject @procname wguP/&  /$P/' /'P/( /( P/) /)H4/|7/́CV0&%|%,%$ P  0 L  | `@P`p 0PxD\P/~# /~#4/~%6/~s @%$d$$#$#4d(@h$0p t0X(\1) exec dbo.sp_MSindexcolfrombin @join_objid`eX(/DJ/x8T7 user_transaction /Gt/J/ **Gset hljce4/7/(@f0D\ + ' = ' + @join_table + '.' + @joincol /* PJ/D c/(AHyId 7.sp_MSmaketempinsertproc|/ f/ C0&HC@tablename \/ t/ $6H$@tablename|/ f/A0&HA@@procname\/ t/"6H"@procnameP/  /HP/  /HP/  /H$.} / H4/  P+`0*HP 7 `sp_MSmakete@pinsertproct/  "/<6H<sp_MSmaketempinsertprocD/  [/ HH!/7SplitNextD/ !//@x2L/!@L/!*#@L/@!@*66 /!/)g 0*eH)xpstar.dll0TȚHg create proc sp_help_fulltext_catalogs_cursor @cursor_return CURSOR VARYING OUTPUT, @fulltext_catalog_name sysname = NULL -- full-text catalog name as -- @FULLTEXT MUST BE ACTIVE IN DATABASE -- if DatabaseProperty(db_name(), 'IsFulltextEnabled') = 0 begin raiserror(15601,-1,-1) return 1 end -- CATALOG MUST EXIST IF SPECIFIED -- if @fulltext_catalog_name is not null begin de@clare @ftcatid smallint select @ftcatid = ftcatid from sysfulltextcatalogs where name = @fulltext_catalog_name if @ftcatid is null begin raiserror(15602,-1,-1,@fulltext_catalog_name) return 1 end end -- RETRIEVE THE DE@FAULT PATH -- DECLARE @def_path as nvarchar(260) select @def_path = null exec master.dbo.xp_regread 'HKEY_LOCAL_MACHINE', 'SOFTWARE\Microsoft\MSSQLServer\MSSQLServer','FullTextDefaultPath', @def_path OUT -- SELECT ANY ROWS THAT MEET THE CRI@TERIA -- set @cursor_return = CURSOR LOCAL SCROLL DYNAMIC FOR select CAT.ftcatid, name as NAME, 'PATH'= CASE WHEN path is NULL THEN @def_path ELSE path END, FullTextCatalogProperty(C@AT.name, 'PopulateStatus') AS STATUS , (select COUNT(*) from sysobjects where type='U' and sysobjects.ftcatid = CAT.ftcatid ) as NUMBER_FULLTEXT_TABLES from sysfulltextcatalogs as CAT where ( @fulltext_catalog_name is null or name = @@fulltext_catalog_name ) order by ftcatid open @cursor_return -- SUCCESS -- return 0 -- sp_help_fulltext_catalogs_cursor o</ !/ x8L/!)/#*eH P/ ! /*4/!H7/V0L@\`p<\q  select @uid = min(uid)+1 from sysusers where uid >= 5 and uid < (16384 - 1) -- stay in users range and user_name(uid+1) is null -- uid not in use if @uid is null begin raiserror(15065,-1,-1) return (1) end -- ADD IMPLICIT SYSUSERS ENTRY -- mP/D c/(A՜3~4\/6&sp_MSsetlastsentgen t/F/;0&՜3$$;@repidT/Y/6՜3@repidx/G/=0&՜388 =@srcgeneinX/@Z/6՜3@srcgenshx/H/?0&՜3$$?@srcguidbX/[/ 6՜3 @srcguidP/& / ՜3˧iL RP/ & / ՜3s", / ՜3/ H/X0*՜3P /6 Xsp_MSsetlastsentgenl/ ]/ 46՜34sp_MSsetlastsentgenD/ Z/ ՜3/(r0՜3r CREATE PROCEDURE sp_MS4SRRDR22t2(21H#""d" "!!! &%|%,%$ P  0 L  | `@L@\`p<\@@@.H6P4-. .-%O}-#0d  CREATE PROCEDURE sp_changemergesubscription ( @publication sysname = NULL, /* Publication name */ @subscriber sysname = NULL, /* Subscriber server */ @subscriber_db sysname = NULL, /* Subscription database */ @property sysname = NULL, /* The property to change */ @value nvarchar(255) = NULL /* The new property value */ ) AS @ SET NOCOUNT ON /* ** Declarations. */ declare @subscriber_bit smallint declare @subscriber_srvid int declare @publisher_srvid int declare @retcode int declare @pubid uniqueidentifier declare @subid uniqueidentifier declare @partnerid uniqueidentifier declare @sync_typeid tinyint declare @nosync tinyint declare @automatic @ tinyint declare @artid uniqueidentifier declare @schematype int declare @schemaversion int declare @schemaguid uniqueidentifier declare @db_name sysname declare @subscriber_type int declare @schematext nvarchar(2000) declare @publisher sysname declare @publisher_db sysname /* ** Initializations. */ SET @nosync =@2 /* Const: synchronization type 'none' */ SET @automatic = 1 /* Const: synchronization type 'automatic' */ set @publisher = @@SERVERNAME set @publisher_db = DB_NAME() /* ** Security Check. */ BEGIN exec @retcode = dbo.sp_MSreplcheck_subscribe if @@ERROR <> 0 or @retcode <> 0 return(1) END /* ** Check to see if current database is doing publishing/subscribing */ IF not exists (select name f@om sysobjects where name='sysmergesubscriptions') BEGIN RAISERROR (14055, 16, -1) RETURN (1) END /* ** Parameter Check: @property. ** If the @property parameter is NULL, print the options. */ IF @property IS NULL BEGIN CREATE TABLE #tab1 (properties sysname) INSERT INTO #tab1 VALUES ('sync_type') INSERT INTO #tab1 VALUES ('priority') INSERT INTO #tab1 VALUES ('description')@ select * FROM #tab1 RETURN (0) END /* ** Parameter Check: @publication. ** Make sure that the publication exists. */ IF @publication IS NULL BEGIN RAISERROR (14043, 16, -1, '@publication') 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 BEGIN@ RAISERROR (20026, 11, -1, @publication) RETURN (1) END /* ** Validate that the publisher is a valid server */ select @publisher_srvid = srvid from master..sysservers where UPPER(srvname) = UPPER(@publisher) IF @publisher_srvid IS NULL BEGIN RAISERROR (14010, 16, -1) RETURN (1) END /* ** Parameter Check: @subscriber. ** Check to make sure we have a valid subscriber. */ IF @su@scriber IS NULL BEGIN RAISERROR (14043, 16, -1, '@subscriber') RETURN (1) END /* ** Validate that the subscriber is a valid server */ select @subscriber_srvid = srvid from master..sysservers where UPPER(srvname) = UPPER(@subscriber) IF @subscriber_srvid IS NULL BEGIN RAISERROR (14010, 16, -1) RETURN (1) END /* ** Check to see if you have a local / global subscription on this publicat@on <. O-$}x8L.O)N-d } P. O -4-!OH6-!V0- M}.0d  */ set @subid = NULL select @subid = subs1.subid, @pubid = pubs.pubid, /* identified from publication name */ @subscriber_type=@ubs1.subscriber_type, @partnerid = subs2.subid 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 @ and UPPER(pubs.publisher)=UPPER(@@servername) and pubs.publisher_db=db_name() if @subid IS NULL begin RAISERROR (14050, 11, -1) RETURN(1) end /* ** Parameter Check: @property. ** Check to make sure that @property is a valid property in ** sysarticles. */ IF LOWER(@property) NOT IN ('sync_type', 'priority', 'description') BEGIN RAISERROR (20078, 16, -1) @ RETURN (1) END /* ** Change the property. */ IF LOWER(@property) = 'sync_type' BEGIN /* ** Check to make sure that we have a valid sync_type. */ IF LOWER(@value) NOT IN ('automatic', 'none') BEGIN RAISERROR (14052, 16, -1) RETURN (1) END /* ** Determine the integer value for the sync_type. @/ IF LOWER(@value) = 'automatic' SET @sync_typeid = @automatic ELSE BEGIN /* ** If current publication contains an article without rowguidcol, do not allow no-sync subscription */ if exists (select * from sysmergearticles a where pubid = @pubid and not exists (select * from syscolumns c where c.id=a.objid and columnproperty (c.id, c.name, 'isrowguidcol')=1)) begin @ Raiserror(20086, 16, -1, @publication) RETURN (1) end else SET @sync_typeid = @nosync END /* ** Update the subscription with the new sync_type. */ UPDATE sysmergesubscriptions SET sync_type = @sync_typeid WHERE subid = @subid IF @@ERROR <> 0 BEGIN RAISERROR (14053, 16, -1) @RETURN (1) END END IF LOWER(@property) = 'description' BEGIN UPDATE sysmergesubscriptions SET description = @value WHERE subid = @subid IF @@ERROR <> 0 BEGIN RAISERROR (14053, 16, -1) RETURN (1) END END IF LOWER(@property) = 'priority' BEGIN select @db_name = db_na@e from sysmergesubscriptions where (pubid=@pubid) and (subid=@pubid) IF @db_name <> db_name() BEGIN RAISERROR (20047, 16, -1) RETURN (1) END /* Only the original publisher can change priority of a global subscriptions */ IF @subscriber_type<>1 BEGIN RAISERROR (20044, 16, -1) /* Local subscriber does not have priority*/ RETURN (1) END IF convert(real, @v@lue)>100.0 BEGIN RAISERROR (20049, 16, -1) /* Don't accept priority greater than 100 */ RETURN (1) END select @schemaversion = schemaversion from sysmergeschemachange *HP/H6SplitNextD. P-"/ i@ LOL.P~0}|L. P}@|or~6,L. P|-%}c_~= L. P)O.d ~ 0P. P .4.PH6.V0T.M~. 0d if (@schemaversion is NULL) set @schemaversion @= 1 else select @schemaversion = 1 + max(schemaversion) from sysmergeschemachange set @schemaguid = newid() set @artid = newid() set @schematype = 8 /* change priority */ se@lect @schematext = 'exec dbo.sp_MSchange_priority '+ '''' + convert(nchar(36),@subid) + '''' + ',' + '''' + @value + '''' BEGIN TRANSACTION change_priority exec dbo.sp_MSchange_priority @subid, @value if @@ERROR<>0 g@oto UNDO exec @retcode=sp_MSinsertschemachange @pubid, @artid, @schemaversion, @schemaguid, @schematype, @schematext if @@ERROR<>0 or @retcode<>0 goto UNDO COMMIT TRANSACTION END /* ** Return succeed. I@t is not an error message. */ RAISERROR (14054, 10, -1) RETURN (0) UNDO: if @@TRANCOUNT = 1 ROLLBACK TRANSACTION else COMMIT TRANSACTION return (1) (P. M . P. MH.P. M. P. M.4-MH6-smr,,8,++D##"t"("!!L!!D's/P@L-2+o0nL-3+n-0o.am * sib r X..'D-7TQ6 user_transaction .'Qd t.'Q.' **d - 2 in f h as4.'Q6.'(@Q0D\eld' ,pr.spid from master.dbo.sysprocesses pr left outer join master.dbo.syslocks lk on pr.spid=lk.spid ,mastX0.(@R6 grrev L.(RT -d  P.( R . 4.(R6.(dV0>0Xameter_name sysname, @parameter_value nvarchar(255) )AS declare @slash_parameter_name sysname declare @dash_parameter_name sysname declare @retcode int select @paraP6<:<.)D c-(A&Y_6&Y>sp_helpmergesubscriptionULD.)SZ- &YH@/t6SplitNextD.) T./ if@(@nL.)TL.)T-<> L.)T(%RN h.)T.)-0k-SQLTrace.dll db<.) T.)@x8L.) T)R. kRRP.)! T .(4.)Tt6.)V0.)S.)0&Y CREATE PROCEDURE sp_helpmergesubscription( @publication sysname = '%', /* Publication name */ @subscriber sysname = '%', /* Subscriber server */ @subscriber_db sysn@me = '%', /* Subscription database */ @publisher sysname = '%', /* Publisher server */ @publisher_db sysname = '%', /* Publisher database */ @subscription_type nvarchar(15) = 'both', /* Subscription type - push or pull */ @found int = NULL OUTPUT )AS SET NOCOUNT ON /* ** Declarations. */ declare @db sysname declare @retcode int declare @subscriber_bit smallint de@lare @srvid int declare @pubid uniqueidentifier declare @subid uniqueidentifier declare @partnerid uniqueidentifier declare @cursor_open int declare @no_row bit declare @subscription_type_id int /* ** Initializations. */ set @subscriber_bit = 4 set @cursor_open = 0 /* ** Initializations of @now_row. */ IF @found is NULL BEGIN @ SELECT @no_row=0 END ELSE BEGIN SELECT @no_row=1 END select @db=db_name() -- so that it can appear in dynamic query /* ** Calling sp_help* is all right whether current database is enabled for pub/sub or not */ IF not exists (select * from sysobjects where name='sysmergesubscriptions') RETURN (0) /* Security check */ EXEC @retcode = dbo.sp_MSreplcheck_pull @publication = @publication, @raise_fatal_error = 0 @ if @@ERROR <> 0 or @retcode <> 0 return(1) /* ** Parameter Check: @subscription_type. ** Set subscription_typeid based on the @subscription_type specified. ** ** subscription_type subscription_type ** ================= =============== ** 0 push ** 1 pull ** 2 both */ if LOWER(@subscription_type) NOT IN ('push', 'pull', 'both') BEGIN RAISERROR @20079, 16, -1) RETURN (1) END IF LOWER(@subscription_type) = 'both' set @subscription_type_id = 2 else IF LOWER(@subscription_type) = 'push' set @subscription_type_id = 0 else set @subscription_type_id = 1 /* ** Parameter Check: @publisher ** Check to make sure that the publisher is defined */ IF @publisher <> '%' BEGIN EXECUTE @retcode = dbo.sp_validname @publisher IF @@ERROR <> 0 OR @retcode@<> 0 RETURN (1) END /* ** Parameter Check: @subscriber. ** If remote server, limit the view to the remote server's subscriptions. ** Make sure that the name isn't NULL. */ if @subscriber IS NULL BEGIN RAISERROR (14043, 16, -1, '@subscriber') RETURN (1) END /* ** Parameter Check: @subscriber. ** Check if remote server is defined as a subscription server, and ** that the name conforms to the @ules for identifiers. */ if @subscriber <> '%' BEGIN EXECUTE @retcode = dbo.sp_validname @subscriber if @retcode <> 0 OR @@ERROR <> 0 RETURN (1) if NOT EXISTS (select * FROM master..sysservers WHERE UPPER(srvname) = UPPER(@subscriber) AND (srvstatus & @subscriber_bit) <> 0) BEGIN --RAISERROR (14010, 16, @1) RETURN (1) END END /* ** Parameter Check: @publication. ** If the publication name is specified, check to make sure that it e HU/t6SplitNext8.)%U-ZV0L.)& U.)/D.)' U.)'/ @ 8.)( U-Z@x8L.))U0L.)*U.)$woL.)+U.)  L.),U)S.)!&Y P.)- U .)"4.)%Ut6.)%V0.)$S.)*0&Y@ ** conforms to the rules for identifiers and that the publication ** actually exists. Disallow NULL. */ if @publication IS NULL BEGIN RAISERROR (14043, 16, -1, '@publication') RETURN (1) END /* ** Get subscriptions */ if @publication <>'%' begin execute @retcode = dbo.sp_MSsubsetpublication @publication if @@ERROR <> 0 or @retcode<>0 Return (1) end creat@ table #helpsubscription ( publication sysname NOT NULL, publisher sysname NOT NULL, publisher_db sysname NOT NULL, subscriber sysname NOT NULL, subscriber_db sysname NOT NULL, status int NOT NULL, subscriber_type int NOT NULL@ subscription_type int NOT NULL, priority float(8) NOT NULL, sync_type tinyint NOT NULL, description nvarchar(255) NULL, merge_jobid binary(16) NULL, full_publication tinyint NULL ) /* ** Performance Optimization: Eliminate the 'LIKE' clause for publication name. *@ Empirical evidence shows almost 50% speed improvement when ** opening the cursor if publication name is provided. */ IF (@publication <> '%') 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, rep@info.merge_jobid, pubs.publication_type 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 su@s2.subid = subs1.partnerid and pubs.pubid = subs1.pubid and pubs.pubid = subs2.pubid and servers1.srvid = subs1.srvid and servers2.srvid = subs2.srvid and pubs.name = @publication 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 subs1.db_name like @subscriber_db and subs2.db_name like @publisher_db and ((@subscriber = N'%') or (UPPER(servers1.srvname) = UPPER(@subscriber))) and ((@publisher = N'%') or (UPPER(servers2.srvname) = UPPER(@publisher))) and (subs1.subscription_type = @subscription_type_id or @subscription_type_id = 2) ELSE insert into #helpsubscription select distinct pubs.name, servers@.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 FROM sysmergesubscriptions subs1, sysmergesubscriptions subs2, MSmerge_replinfo r.)0S.)0r0&Yrepl@nfo, 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 subs1.db_name like @subscriber_db and subs2.db_name like @publisher_db and ((@subscriber = N'%') or (UPPER(servers1.srvname) = UPPER(@subscriber))) and ((@publish@r = N'%') or (UPPER(servers2.srvname) = UPPER(@publisher))) 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 IF LOWER(@subscription_type) = 'push' or LOWER(@subscription_type) = 'both' begin select 'subscription_name' = subscriber + ':' + subscrib@r_db, * from #helpsubscription order by publisher, publisher_db, publication, subscriber, subscriber_db end else begin select 'subscription_name' = publisher + ':' + publisher_db + ':' + publication, * from #helpsubscription order by publisher, publisher_db, publication, subscriber, subscriber_db end select @retcode = 0 DONE: if (@cursor_open = 1) begin close #cursor dealloca@e #cursor end drop table #helpsubscription return @retcode @rP.)1 S .).P.)2 S.)2P.)3 S.)3 P.)4 S.)44.)St6.) 9L988\8/<X D  P  ` H | 8 4 x(8 (@h @\EGIN CREATE TABLE #tab1 (properties sysname) INSERT INTO #tab1 VALUES ('description') INSERT INTO #tab1 VALUES ('status') INSERT INTO #tab1 VALUES ('retention') INSERT INTO #tab1 VALUES ('sync_mode') INSERT INTO #tab1 VALUES ('allow_push') INSERT INTO #tab1 VALUES ('allow_pull') INSERT INTO #tab1 VALUES ('allow_anonytee i2 bl*,e-r ( ca2T)uX<.GD .)7TV6 user_transaction .GV&Yt.GV .G **&Y', ret b)d be4.GV6.G(@Q0D\ RETURN (1) end /* ** Parameter Check: @publication. ** Make sure that the publication exists.X0.H@W6 grrev6,L.HWX .(&Y P.H W .)5 4.HW6.HdV0[0X) set @pubidstr = '''' + convert(nchar(36), @pubid) + '''' if @pubid IS NULL BEGIN RAISERROR (20026, 16, -1, @publication) RETURN (1) END else P" .ID c.)(A_x.IX F->6_sp_dropmergesubscriptionriD.IX@Z.) _ @ OR @retcode <> 0 RETURN (1) /* ** Parameter Check: @publisher_db */ IF @publisher_db IS NULL BEGIN RAISERROR (14043, 16, -1, '@publisher_db') RETURN (1) END end /* ** Parameter Check: @publication. ** If the publication name is specified, check to make sure that it ** conforms to the rules for identifiers and that the publication ** a@tually exists. Disallow NULL. */ if @publication IS NULL BEGIN RAISERROR (14043, 16, -1, '@publication') RETURN (1) END IF LOWER(@publication) = 'all' BEGIN declare hC1 CURSOR LOCAL FAST_FORWARD FOR select DISTINCT name FROM sysmergepublications where UPPER(publisher)=UPPER(@@SERVERNAME) and publisher_db=db_name() FOR READ ONLY OPEN hC1 FETCH hC1 IN@O @publication 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 hC1 INTO @publication END CLOSE hC1 DEALLOCATE hC1 RETURN (0) END if NOT EXISTS (select * FROM sysmergepublications WHERE name = @publication and UPPER(publisher)=UPPER(@@servername) and publisher_db=db_name()) BEGIN RAISERROR (20026, 16, -1, @publication) RETURN (1) END select @pubid = pubid from sysmergepublications @ where name = @publication and UPPER(publisher)=UPPER(@@servername) and publisher_db=db_name() set @pubidstr = '''' + convert(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 &  H@Z/6SplitNextD.P Z.I/@L.PZ0 L.PZ.P  *L.PZ .I6L.PZ)Z.I _ 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..@ysservers where UPPER(srvname) = UPPER(@subscriber) 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 sy@mergesubscriptions.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, @subsc@iber_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 @aster..sysservers where UPPER(srvname) = UPPER(@publisher) 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 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 t @.P X.P 0_ @partnerid) begin /* ** global/republisher subscriptions have to stay for a while even after being ** dropped so that they won't regai@ 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 @nd else begin update sysmergesubscriptions set status=2 where subid=@subid IF @@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_addmergesubscr@ption is being called then. */ IF LOWER(@subscription_type) = '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 = @subscri@er, @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, @publicati@n, @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 @ROM master..sysdatabases WHERE name = DB_NAME())=0 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_CLOS@_ON_COMMIT ON END H[/6SplitNextD.P  [.P/ele@t @L.P[0 L.P[.P  vee,L.P[ .PxielL.P[)[.P_ 0 be@gin 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_at_c@ommit <>0 SET CURSOR_CLOSE_ON_COMMIT ON END return (1) atiP.P X .PP.P X.PP.P X.P  P.P X.P4.IX6.IORCHI|I,IHHXD$DCC 0 or @retcode <> 0 or @distributor IS NULL or @distribdb IS NULL BEGIN IF L@WER(@value) = 'true' RAISERROR (20028, 16, -1) ELSE RAISERROR (20029, 16, -1) RETURN (1) END end /* ** Enable the database for publishing. */ IF LOWER(@value) = 'true' BEGIN select @cmptlevel = cmptlevel from master..sysdatabases where name=db_name() if @cmptlevel<70 OR @cmptlevel is NULL begin RAISERROR(20061, 16, -1) @ goto FAILURE end execute @retcode = dbo.sp_MScreate_mergesystables if @@ERROR <> 0 or @retcode <> 0 begin goto FAILURE end END ELSE /* Disable the database for publishing. */ BEGIN /* ** Remove all the registration entries for subscriptions */ if not exists(select * from sysobjects where name = 'sysmergesu@scriptions') goto FAILURE exec @retcode = dbo.sp_dropmergesubscription @publication = 'all', @subscriber = 'all', @subscriber_db = 'all', @subscription_type = 'both', @ignore_distributor = @ignore_distributor IF @@ERROR <> 0 or @retcode <> 0 begin @ goto FAILURE end /* ** Remove all publications and articles in the database. */ EXEC @retcode = dbo.sp_dropmergepublication @publication = 'all', @ignore_distributor = @ignore_distributor IF @@ERROR <> 0 or @retcode <> 0 begin -- sp_dropmergepublication will raiserror goto FAILURE end If NOT EXISTS (s@lect * from sysmergepublications) BEGIN execute @retcode = dbo.sp_MSdrop_mergesystables if @@ERROR <> 0 or @retcode <> 0 begin goto FAILURE end END END return 0 FAILURE: return (1) P.x ^ .xP.x ^HxP.x ^.x P.x ^.x4.x^6.x́CJ0|,l8` `p ,\L-9-MtQL-9't@-.e b O mmX.D.xhT`6 user_transaction .``At.`. **`ASCA' t XfZ th4.`6.(@Q0D\er than sampling @norecompute CHAR(12)= 'NO' -- Optional 'NORECOMPUTE' text - if present, then statistics -- wilP.D c.x(Aф5 )`a6,sp_enumcustomresolvers.ac).xG0&ф5G@distributore`.awM.x(6ф5(@distributorP.aG (Lф5W`mbe .a@ф5.a.^0*ф5P 6 ^sp_enumcustomresolvers t.a.):6ф5:sp_enumcustomresolverse D.aZ.x ф5Hb/6SplitNextD.  b.x/ DE@LARL. b@L. b` REL. b(LTISO.b. 0@create procedure sp_columns_rowset;5 ( @table_server sysname, @table_catalog sysname = null, @table_name sysname = null, @table_schema sysname = null, @column_name sysname = null ) as select TABLE_CATALOG, @ TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, COLUMN_GUID, COLUMN_PROPID, ORDINAL_POSITION, COLUMN_HASDEFAULT, COLUMN_DEFAULT, COLUMN_FLAGS, IS_NULLABLE, DATA_TYPE, TYPE_GUID, CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH, NUMERIC_PRECISION, NUMERIC_SCALE, DATETIME_PRECISION, CHARACTER_SET_CATALOG, CHARACTER_SET_SCHEMA, CHARACTER_SET_NAME, COLLATION_CATALOG, COLLATION_SCHEMA, COLLATION_NAME, DOMAIN_CATALOG, DOMAIN_SCHEMA, DOMAIN_NAME,@ DESCRIPTION from master.dbo.SYSREMOTE_COLUMNS < @table_server, @table_catalog, @table_schema, @table_name, @column_name > order by 1, 2, 3, 7 -<. b. x8L.b)b.x@E P. b .x4. b6. V0t. a.;0ф5@; CREATE PROCEDURE sp_enumcustomresolvers -- @distributor parameter will be removed in the next version. @distributor sysname = NULL AS SET NOCOUNT ON declare @distributor_rpc sysname declare @return_status int declare @distproc nvarchar(100) declare @retcode int select @return_status = 0 /* ** Get the distributor ** Use local RPC if @distributor == @servername. This is used by UI ** before installing a distributor@ */ if @distributor = @@servername select @distributor_rpc = @@servername else begin EXEC @return_status = dbo.sp_helpdistributor @rpcsrvname = @distributor_rpc OUTPUT IF @@error <> 0 OR @return_status <> 0 OR @distributor_rpc IS NULL BEGIN RAISERROR (20036, 16, -1) RETURN (1) END end declare @key_exists int select @key_exists = 0 create table #keyexists (keyexists int) select @distproc = @TRIM(@distributor_rpc) + '.master..xp_regread' insert into #keyexists exec @distproc 'HKEY_LOCAL_MACHINE', 'SOFTWARE\Microsoft\MSSQLServer\Replication\ArticleResolver' select @key_exists = keyexists from #keyexists if (@key_exists = 1) begin select @distproc = RTRIM(@distributor_rpc) + '.master..xp_regenumvalues' exec @distproc 'HKEY_LOCAL_MACHINE', 'SOFTWARE\Microsoft\MSSQLServer\Replication\ArticleResolver' if @@ERROR<>0 return (1) H end drop table #keyexists RETURN (0) rP. a .P. a.P. a. P. a.4.a6.́CJ0t$4 < 4\ <\char(255) declare @db_na R. X.D.x8Tc6 user_transaction .cф5t.c. **ф5 2 S ^c`or_4.c6.(@Q0D\SET CURSOR_CLOSE_ON_COMMIT OFF END /* ** Initializations. */ select @db_name = db_name() /* X0.@d>6 grrevERL.db .wф5 P. d . 4.d>6.dV050X END if LOWER(@publication) = 'all' BEGIN declare hC1 CURSOR LOCAL FAST_FORWARD FOR select DISTINCT name FROM sysmergepublications where UPPP!#$.D c.(A )C\e6(sp_changemergefilter.ec9.G0& )G@publicationb`.ew].(6 )(@publicationx.ec:.?0& )?@@article X.ew]. 6 ) @article.ec;.E0& )E@filtername. `.ew^.&6 )&@filternameio|.ec<.A0& )A@property -1\. ew_."6 )@"@propertyrgt. ec=. ;0& );@valueeT. ewa. 6 )@valueP. eW . )eandP. eW .  )t t .e ).e$.Z0* )P @6 Zsp_changemergefilter p.eU-66 )6sp_changemergefilter@pD.eZ.   )Hf/6SplitNextD. f. / AN@ suL.fL.f(L@biubL.f(`   L.f)e. )meP. f .4.f6.V0.e.0 ) create procedure sp_changemergefilter( @publication sysname, @article sysname, @filterna@e sysname, @property sysname, @value nvarchar(2000) )AS set nocount on declare @db_name sysname declare @pubid uniqueidentifier declare @artid uniqueidentifier declare @retcode int declare @join_filterid int declare @join_objid int declare @join_nickname int /* ** Security Check. ** Only the System Administrator (SA) or the Database Owner (dbo) can @ ** call this procedure */ exec @retcode = dbo.sp_MSreplcheck_publish if @@ERROR <> 0 or @retcode <> 0 return(1) /* ** Parameter Check: @join_articlename. ** The join_articlename cannot be NULL */ if @filtername is NULL begin raiserror (14043, 11, -1, '@filtername') return (1) end if @value is NULL or @value = '' begin raiserror (14043, 11, -1, '@value') return (1) @ end /* ** Parameter Check: @publication. ** The @publication id cannot be NULL and must conform to the rules ** for identifiers. */ if @publication is NULL begin raiserror (14043, 11, -1, '@publication') return (1) end /* ** Get the pubid and make sure the publication exists */ select @pubid = pubid from sysmergepublications where name = @publication and UPPER(publisher)=UPPER(@@servername) and publ@sher_db=db_name() if @pubid is NULL begin raiserror (20026, 16, -1, @publication) return (1) end /* This can only be done at the publisher */ exec @retcode = dbo.sp_MScheckatpublisher @pubid if @retcode <> 0 or @@ERROR <> 0 return (1) /* ** This can be done for articles that are not active. */ if EXISTS (select status FROM sysmergearticles WHERE pubid = @pubid AND status = 2) BEGIN RAISERROR@(20043, 16, -1, @article) RETURN (1) END select @db_name = db_name from sysmergesubscriptions where (pubid=@pubid) and (subid=@pubid) IF @db_name <> db_name() BEGIN RAISERROR (20047, 16, -1) RETURN (1) END /* ** Parameter Check: @article. ** Check to see that the @article is valid and does exist */ if @article is NULL begin raiserror (20045, 16, -1) return@(1) end select @artid = artid from sysmergearticles where name = @article and pubid = @pubid if @artid is NULL begin raiserror (20046, 16, -1) return (1) end select @join_filterid=join_filterid from sysmergesubsetfilters where pubid=@pubid and artid=@artid and filtername=@filtername if @join_filterid is null begin raiserror (14028, 16, -1) return (1) end @ IF @property IS NULL BEGIN CREATE TABLE #temp (properties sysname) INSERT INTO #temp VALUES ('filtername') INSERT INTO #temp VALUES ('join_filterclause') INSERT INTO #temp VALUES ('join_articlename') select * FROM #tab1 RETURN (0) END if @value is null begin raiserror (14028, 16, -1) return (1) end IF LOWER(@property)='join_filterclause' @EGIN update sysmergesubsetfilters set join_filterclause=@value where join_filterid=@join_filterid execute @retcode = dbo.sp_MSsubsetpublication @publication if @@ERROR <> 0 or @retcode<>0 goto FAILURE Eupd.e.0 )ND IF LOWER(@property)='filtername' BEGIN upd@ate sysmergesubsetfilters set filtername=@value where join_filterid=@join_filterid END IF LOWER(@property)='join_articlename' BEGIN select @join_objid = objid from sysmergearticles where name = @value @and pubid = @pubid IF @join_objid is NULL BEGIN raiserror (14027, 11, -1, @value) return (1) END select @join_nickname = nickname from sysmergearticles wh@ere pubid = @pubid AND objid = @join_objid if @join_nickname is NULL begin raiserror (20001, 11, -1, @article, @publication) return (1) end update sysmerge@subsetfilters set join_articlename=@value, join_nickname=@join_nickname where join_filterid=@join_filterid END return(0) FAILURE: RAISERROR (20038, 16, -1, @article, @publication) return(1) db P. eH .P. e.P. e. P. e.4.e6. $#""4"! 0 `|8<8 Hh8\ EXECUTE @retcode = @distproc @publisher = @@SERVERNAME, B i mX$.D$.hTg6 user_transaction .g )t.g$. ** )@puid Z \> 04.g6.(@Q0D\n from sysmergepublications. */ DELETE FROM sysmergepublications WHERE name = @publication aX0.@hj6 grrev 0L.hf . ) P. h . 4.hj6.dV0X0X_at_commit <>0 SET CURSOR_CLOSE_ON_COMMIT ON END return (0) FAILURE: RAISERROR (14006, 16, -1) /* UNDONE : This code is specific to 6.X nested transaction semantics */ P&+,.D c.(AC|Xi6"sp_addmergefiltered.ic[. G0&CG@publicationR`.i--(6C(@publicationx.ic\.?0&C?@ar@ticleX.i. 6C @article.ic].E0&CE@filternameJI`.i.&6C&@filternamei.ic^.Q0&CQ@join_articlenamesl. i.@26C2@join_articlename. ic_. S0&CS@join_filterclausel. i. 46C4@join_filterclause. ic`. O0&C88 O@join_unique_keyh. i. 06C@0@join_unique_keyP.i> (CP.i? .Ce P.i? .CP.i? .CP.i? .C .iC.i+.@T0*CP 6 Tsp_addmergefilterh.i".06C0sp_addmergefilterD.iZ. C.i/50C create procedure sp_addmergefilter( @publication sysname, /* publication name */ @article sysname, /* artic@e name */ @filtername sysname, /* join filter name */ @join_articlename sysname, /* Name of the table being joined to the base table */ @join_filterclause nvarchar(2000), /* filter clause qualifying the join */ @join_unique_key int = 0 )AS set nocount on /* ** Declarations. */ declare @db_name sysname declare @pubid uniqueidentifier @eclare @artid uniqueidentifier declare @art_nickname int declare @join_nickname int declare @db sysname declare @object sysname declare @owner sysname declare @retcode int declare @join_objid int declare @status int /* ** Only publisher can run this stored procedure */ if not exists (select * from sysobjects where name = 'sysmergepublications') @ BEGIN RAISERROR (20054, 16, -1) RETURN (1) END /* ** Security Check. ** Only the System Administrator (SA) or the Database Owner (dbo) can ** add an article to a publication. */ exec @retcode = dbo.sp_MSreplcheck_publish if @@ERROR <> 0 or @retcode <> 0 return(1) /* ** Parameter Check: @filtername. ** The join_filter_name cannot be NULL */ if @filtername is NULL begin ra@serror (14043, 11, -1, @filtername) return (1) end if @join_filterclause is NULL or @join_filterclause = '' begin raiserror (14043, 11, -1, '@join_filterclause') return (1) end /* ** Parameter Check: @publication. ** The @publication id cannot be NULL and must conform to the rules ** for identifiers. */ if @publication is NULL begin raiserror (14003, 16, -1) return (1)@ end /* ** Get the pubid and make sure the publication exists */ select @pubid = pubid from sysmergepublications where name = @publication and UPPER(publisher)=UPPER(@@servername) and publisher_db=db_name() if @pubid is NULL begin raiserror (14027, 16, -1, @publication) return (1) end /* This can only be done at the publisher */ exec @retcode = dbo.sp_MScheckatpublisher @pubid if @retcode <> 0 o@ @@ERROR <> 0 return (1) select @db_name = db_name from sysmergesubscriptions where (pubid=@pubid) and (subid=@pubid) IF @db_name <> db_name() BEGIN RAISERROR (20047, 16, -1) RETURN (1) END /* ** This can be done for articles belonging to publications that are not active. */ if EXISTS (select status FROM sysmergepublications WHERE pubid = @pubid AND status = 2) BEGIN RAISERROR (20043@ 16, -1, @article) RETURN (1) END /* ** Parameter Check: @article. ** Check to see that the @article is valid and does exist */ if @article is NULL begin raiserror (20045, 16, -1) return (1) end select @artid = artid, @art_nickname = nickname from sysmergearticles where name = @article and pubid = @pubid if @artid is NULL begin raiserror (20046, 16, -1) @ return (1) end /* ** Get the id of the @join_articlename */ select @join_objid = objid from sysmergearticles where name=@join_articlename and pubid = @pubid IF @join_objid is NULL BEGIN Hj/ 6SplitNextD. j./all@catL.j/L.j/.@CK L.j(g/ L.j)q.CP. j .4.j 6.V0.i.y0Cy raiserror (14027, 11, -1, @join_articlename) @ return (1) END select @join_nickname = nickname from sysmergearticles where pubid = @pubid AND objid = @join_objid if @join_nickname is NULL begin raiserror (20001, 11, -1, @article, @publication) @ return (1) end IF NOT EXISTS (select * from sysmergearticles where pubid=@pubid AND nickname = @join_nickname) BEGIN RAISERROR (20046, 16, -1) /* Only the original publisher can do so */ RETURN (@1) END /* ** Make sure that the table name specified is a table and not a view. */ if NOT exists (select * from sysobjects where id = @join_objid AND type = 'U') begin raiserror (14028@, 16, -1) return (1) end /* ** Add the join filter to sysmergesubsetfilters if it is not already there */ IF exists (select * from sysmergesubsetfilters where filtername=@filtername and pubid=@pubid and@ artid=@artid) begin raiserror (20002, 16, -1, @filtername, @article, @publication) return (1) end insert INTO sysmergesubsetfilters(filtername, pubid, artid, art_nickname, join_articlename, join_nick@name, join_unique_key, join_filterclause) values(@filtername, @pubid, @artid, @art_nickname, @join_articlename, @join_nickname, @join_unique_key, @join_filterclause) if @@error <> 0 begin goto FAILURE @ end execute @retcode = dbo.sp_MSsubsetpublication @publication if @@ERROR <> 0 or @retcode <>0 goto FAILURE return (0) FAILURE: RAISERROR (20038, 16, -1, @article, @publication) return (1) UwP.! H .P." i."P.# i.# P.$ i.$4.i 6.obi0+**@*)<l D `dt$4<Dd 4\ c p_r c %SQL c W`i ,r i dlX,.D+.TkK6 user_transaction .kCt.k+. **C  TV 4.kK6.(@Q0D\own\ %(@s\ % \ -Che\ -@re\ -X0.@l6 grrev]L.lk .C P. l .% 4.l6.dV0,0X  tio  gin or Ͽ licϿ retϿ  Ͽ  ubiϿ atiPZ.D c.(A|Xm,6$sp_dropmergefilter.mcj. G0&|G@publicationC`.m.(6|(@publicationx.mck.?0&|?@ar@ticlerX.m. 6| @article.mcl.E0&|E@filtername`.m.&6|&@filternameP.mP .|P. mQ . |e . m|@. m1.V0*|P ,6 Vsp_dropmergefilterl. m D.I26|2sp_dropmergefilterD. mZ. |Hn/,6SplitNext8.n.)&V0L. n./@D. n./@8. n.))x8L.n0L.n.0coL.n0(p | .n.; -0; create procedure sp_MSscript_t@rigger_fetch_statement @objid int, @op_type char(3) = 'ins', @indent int = 0 as declare @cmd nvarchar(4000) exec dbo.sp_MSpad_command @cmd output, @indent -- script fetch statements if @op_type in ('i@ns', 'upd') begin exec dbo.sp_MSpad_command @cmd output, @indent select @cmd = @cmd + (N'fetch next from rpl_ins_cursor into ') exec dbo.sp_MSflush_command @cmd output, 1, @indent exec dbo.sp_MSscript_trigger_variables @objid, '@', nu@ll, @indent, ' ' end if @op_type in ('ins') begin exec dbo.sp_MSpad_command @cmd output, @indent select @cmd = @cmd + (N'fetch next from rpl_ins2_cursor into ') exec dbo.sp_MSflush_command @cmd output, 1, @indent exec dbo.sp_@MSscript_trigger_variables @objid, '@', '_old', @indent, ' ' end if @op_type in ('upd', 'del') begin exec dbo.sp_MSpad_command @cmd output, @indent select @cmd = @cmd + (N'fetch next from rpl_del_cursor into ') exec dbo.sp_MSflush_@command @cmd output, 1, @indent exec dbo.sp_MSscript_trigger_variables @objid, '@', '_old', @indent, ' ' end %0-SQLTrace.dll<. n.p x8L.n)s.P. n .4.H,6.V0Tp$TDDd 4\<@C4*<A)*;V0*CP k6 Vsp_changesubstatusnl*<B )26C2sp_changesubstatusgD*<CZ)G CH/k6SplitNenP$. .m.S 0|S create procedure sp_dropmergefilter @publication sysname, /* publication name */ @article sysname, /* article name */ @filtername sysname /* Name of the table being joined to the base table */ AS set nocount on /* ** Declarations. */ declare @pubid uniqueidentifier @ declare @artid uniqueidentifier declare @join_objid int declare @retcode int declare @join_filterid int declare @db_name sysname /* ** Only publisher can run this stored procedure */ if not exists (select * from sysobjects where name = 'sysmergepublications') BEGIN RAISERROR (20054, 16, -1) RETURN (1) END /* ** Security Check.@ */ exec @retcode=sp_MSreplcheck_publish if @@ERROR <> 0 or @retcode <> 0 return (1) /* ** Parameter Check: @publication. ** The @publication id cannot be NULL and must conform to the rules ** for identifiers. */ if @publication is NULL begin raiserror (14003, 16, -1) return (1) end /* ** Get the pubid, and check if this publication exists. */ select @pubid = pubid from sysmergepub@ications where name = @publication and UPPER(publisher)=UPPER(@@servername) and publisher_db=db_name() if @pubid is NULL begin raiserror (20026, 16, -1, @publication ) return (1) end select @db_name = db_name from sysmergesubscriptions where (pubid=@pubid) and (subid=@pubid) IF @db_name <> db_name() BEGIN RAISERROR (20047, 16, -1) RETURN (1) END /* ** Parameter Ch@ck: @article. ** Check to see that the @article is valid, and if it exists */ if @article is NULL begin raiserror (20045, 16, -1) return (1) end /* ** This can be done for articles belonging to publications that are not active. */ if EXISTS (select status FROM sysmergepublications WHERE pubid = @pubid AND status = 2) BEGIN RAISERROR (20043, 16, -1, @article) RETURN (1) END @ select @artid = artid from sysmergearticles where name = @article and pubid = @pubid if @artid is NULL begin raiserror (20046, 16, -1) return (1) end select @join_filterid = join_filterid from sysmergesubsetfilters where pubid = @pubid AND artid= @artid AND filtername=@filtername /* ** Remove the join filter from sysmergesubsetfilters */ delete from sysmergesubsetfilters where join_fi@terid = @join_filterid if @@error <> 0 begin goto FAILURE end /* ** set the pub type to subset or full as appropriate */ exec @retcode=sp_MSsubsetpublication @publication if @@ERROR <> 0 or @retcode<>0 begin goto FAILURE end return(0) FAILURE: RAISERROR (20039, 16, -1, @article, @publication) return (1) xP. m .P.H m.P. m. P. m.4.m,6.́CJ0D jectProperty( id, 'ExecIsInsertTrigger') > @instrig and ObjectProperty( id, 'ExecIsUpdateTrigger') > @ul el X.D1. x8Tow6 user_transaction .o|t.o1. **|the sp V_Xon_4.ow6.(@Q0D\t j.name, 'agent_type' = c.name, 'status' = case isnull(jh.run_status, 5) -- mapped to never run P ".D c.(A9Xp 6$sp_helpmergefilter.p(G0&G@publicationu`.p+.(6(@publicationx.p.?0&?@ar@ticle X.p+. 6 @article.p.E0&E@filternamemsd`.p,.&6&@filtername.jP.p{ . eectP. p{ . _id . p@. p8.V0*P  6 Vsp_helpmergefilter,1l. pC.262sp_helpmergefilterD. pZ. Hq/ 6SplitNextD. q./@L.q@2L.q#*2ceinL.q2(vie d.q.n0$ncreate procedure sp_indexes_rowset;5 ( @table_server sysname, @table_catalog sysname = null, @table_name sysname = null, @index_name sysname = null, @table_schema sysname = null ) as select TABLE_CATALOG, TABLE_SCHEMA, TAB@E_NAME, INDEX_CATALOG, INDEX_SCHEMA, INDEX_NAME, PRIMARY_KEY, "UNIQUE", "CLUSTERED", "TYPE", FILL_FACTOR, INITIAL_SIZE, NULLS, SORT_BOOKMARKS, AUTO_UPDATE, NULL_COLLATION, ORDINAL_POSITION, COLUMN_NAME, COLUMN_GUID, COLUMN_PROPID, COLLATION, CARDINALITY, PAGES, FILTER_CONDITION -- INTEGRATED from master.dbo.SYSREMOTE_INDEXES < @table_server, @table_catalog, @table_schema, @index_name@ NULL, /* TYPE (index type) */ @table_name > order by 8 desc, 4, 5, 6, 17 @<. q.rx8L.q)w.$ P. q .4.q 6.V0.p.0 create procedure sp_helpmergefilter @publication sysname,@ /* publication name */ @article sysname = '%', /* article name */ @filtername sysname = '%' AS set nocount on /* ** Declarations. */ declare @pubid uniqueidentifier declare @artid uniqueidentifier declare @retcode int /* ** Security Check. */ exec @retcode = dbo.sp_MSreplcheck_publish if @@ERROR <> 0 or @retcode <> 0 @ return(1) /* ** Calling sp_help* is all right whether current database is enabled for pub/sub or not */ IF not exists (select * from sysobjects where name='sysmergesubscriptions') RETURN (0) /* ** Parameter Check: @publication. ** The @publication id cannot be NULL and must conform to the rules ** for identifiers. */ if @publication is NULL begin raiserror (14003, 16, -1) return (1) @nd /* ** Get the pubid and check if the publication does exist */ select @pubid = pubid from sysmergepublications where name = @publication and UPPER(publisher)=UPPER(@@servername) and publisher_db=db_name() if @pubid is NULL begin raiserror (20026, 16, -1, @publication) return (1) end /* ** Parameter Check: @article. ** If an @article is specified, make sure it exists */ select @artid = artid from sys@ergearticles where name = @article and pubid = @pubid if @artid is NULL and (@article <> '%' or @filtername <> '%') begin raiserror (20046, 16, -1) return (1) end /* ** Return the join filters from sysmergesubsetfilters */ IF @filtername <> '%' select distinct join_filterid, filtername, 'join article name' = j_a.name, join_filterclause, f.join_unique_key, 'base table owner' = b_u.name, 'base table name' = b_o.name, 'j@in table owner' = j_u.name, 'join table name' = j_o.name, 'article name' = b_a.name from sysmergesubsetfilters f, sysobjects j_o, sysobjects b_o, sysusers j_u, sysusers b_u, sysmergearticles j_a, sysmergearticles b_a where f.pubid = @pubid AND b_a.pubid = @pubid AND f.filtername = @filtername AND f.artid = @artid AND f.artid = b_a.artid AND b_o.id = b_a.objid AND b_u.uid = b_o.uid AND f.join_nick@ame = j_a.nickname AND j_o.id = j_a.objid and j_a.pubid = @pubid AND j_u.uid = j_o.uid ORDER BY j_o.name, b_o.name ELSE begin if @artid is not null select distinct join_filterid, filtername, 'join article name' = j_a.name, join_filterclause, f.join_unique_key, 'base table owner' = b_u.name, 'base table name' = b_o.name, 'join table owner' = j_u.name, 'join table name' = j_o.name, 'article name' = b_a.name from sysmergesubsetfilter@ f, sysobjects j_o, sysobjects b_o, sysusers j_u, sysusers b_u, sysmergearticles j_a, sysmergearticles b_a where f.pubid = @pubid AND b_a.pubid = @pubid AND f.artid = @artid AND f.artid = b_a.artid AND b_o.id = b_a.objid AND b_u.uid = b_o.uid AND f.join_nickname = j_a.nickname AND j_o.id = j_a.objid and j_a.pubid = @pubid AND j_u.uid = j_o.uid ORDER BY j_o.name, b_o.name else select distinct join@filterid, filtername, 'join article name' = j_a.name, join_filterclause, f.join_unique_key, 'base table owner' = b_u.name, 'base table name' = b_o.name, 'join table owner' = j_u.name, 'join table name' = j_o.name, 'article name' = b_a.name from sysmergesubsetfilters f, sysobjects j_o, sysobjects b_o, sys .p.k0kusers j_u, sysusers b_u, sysmerge@articles j_a, sysmergearticles b_a where f.pubid = @pubid AND b_a.pubid = @pubid AND f.artid = b_a.artid AND b_o.id = b_a.objid AND b_u.uid = b_o.uid AND f.join_nickname = j_a.nickname AND j_o.id = j_a.obji@d and j_a.pubid = @pubid AND j_u.uid = j_o.uid ORDER BY j_o.name, b_o.name end return(0) P. p .P. p.P. p. P. pH.4.p6.ct < LXh 4 \ hDDd 4\asguid = 0 set @allhaveguids = 0 end /* ** Process non looping articles that have either a boolean or a join_filter. */ if ( @article_level > 0 OR (len(@bool_filterclause) > 0) ) begin /* ** If the article has a previ_snome ,LX".D8. TrX6 user_transaction .rt.r8. **MSSipp V1X 4.rX6.(@Q0D\ select @quoted_view = QUOTENAME(@viewname) exec ('drop view ' + @quoted_view) X0.@s6 grrev *L.sr . P. s . 4.s6.dV0$0Xjoin_nickname, join_articlename, join_unique_key, join_filterid from sysmergesubsetfilters where pubid=@pubid and artid=@artid FOR READ ONLY open pub1 PV.D c.(A9'^Tt96sp_MSscript_driel.t".G0&9G@publicatione`.t8.(69(@publicationx.t#.?0&9?@arti@cleX.t8. 69 @article .t9.t>.P0*9P 96 Psp_MSscript_drid.tYl.x,69,sp_MSscript_driD. tZ. 9d. t3(|)09)cre@te procedure sp_MSscript_dri (@publication sysname, @article sysname) AS declare @pubid uniqueidentifier select @pubid = pubid from sysmergepublications where name = @publication and UPPER(publisher)=UPPER(@@servername) and publisher_db=db_name() select rkeyid, fkeyid from sysreferences where fkeyid in (select objid from sysmergearticles where pubid = @pubid and name = @article) and rkeyid not in (select objid from sysmergearticles where Hubid = @pubid) o @P. t .P. t. P. t. 4.t96.C&0dl`0\ename and pubid=@pubid) select @join_viewname = object_name(sync_objid) from sysmergearticles where nickname = @join_nick and paX.D>./Tu6 user_transaction .u9t.u>. **9 PfR fr4.u6.(@Q0D\, @join_unique_key, @join_filterid end close pub1 deallocate pub1 X0.@v6 grrev L.vu .9 P. v . 4.v6.dV0"0X join on unique key if (@simple_join_view = 0) set @view_rule = 'select * from ' + @source_object + ' where rowguidcol in (' + @view_rule + ')' end Pd+,.D c.(A'^``we6,sp_MSenumpubreferences.w7.G0&'^G@publicatione`.wM.(6'^(@publicationP.w . '^eeraP.w@ .'^ @h .w'^.wE.^0*'^P e6 ^sp_MSenumpubreferencesemt.wY. :6'^:sp_MSenumpubreferences @D. wZ.  '^Hx/e6SplitNextD.@ x./ @ eL. x5L. x5(ecodL.x(5  .x. B?0lBcreate procedure sp_defaultdb @loginame sysname, -- login name @defdb sysname -- default db as -- SETUP RUNTIME OPTIONS @ DECLARE VARIABLES -- set nocount on declare @ret int -- return value of sp call -- CHECK PERMISSIONS -- IF (not is_srvrolemember('securityadmin') = 1) AND not @loginame = suser_sname() begin raiserror(15132,-1,-1) return (1) end -- DISALLOW USER TRANSACTION -- set implicit_transactions off IF (@@trancount > 0) begin raiserror(15002,-1,-1,'sp_defaultdb') return (1) end -- VALIDATE DATABASE NAME -- if db_id(@defdb) IS NULL begin ra@serror(15010,-1,-1,@defdb) return (1) end -- ADD ROW FOR NT LOGIN IF NEEDED -- if not exists(select * from master.dbo.syslogins where loginname = @loginame) begin execute @ret = sp_MSaddlogin_implicit_ntlogin @loginame if (@ret <> 0) begin raiserror(15007,-1,-1,@loginame) return (1) end end -- CHANGE DEFAULT DATABASE -- update master.dbo.sysxlogins set dbid = db_id(@defdb), xdate2 = getdate() where name = @loginame and sr@id IS NULL -- FINALIZATION: RETURN SUCCESS/FAILURE IF (@@error <> 0) return (1) raiserror(15486,-1,-1) return (0) -- sp_defaultdb 0Qh#?CREATE PROCEDURE sp_grant_publication_access ( @publication sysname, @login sysname, @reserved nvarchar(10) = NULL ) AS -- This stored pr@ocedure can be called repeatedly. DECLARE @distribdb sysname DECLARE @distproc nvarchar (255) DECLARE @retcode int DECLARE @dist_rpcname sysname DECLARE @database sysname -- Security Check exec @retcode = dbo.sp_MSr@eplcheck_publish if @@ERROR <> 0 or @retcode <> 0 return(1) select @database = db_name() -- Existance check of the publication will be done in sp_MSpublication_access -- Note, even if the login exists, it may or may not has acce@ss -- to the server (granted or denied). if @reserved is null begin if not exists (select * from master..syslogins where sid = suser_sid(@login) and hasaccess = 1) begin raiserror(15007, 16, -1, @login) return (1) en@d -- Don't do the user check if sysadmin since sysadmin can enter -- the database as dbo. if is_srvrolemember('sysadmin') = 0 and not exists (select * from sysusers where (sid = suser_sid(@login) or name = N'guest'@) and hasdbaccess = 1) begin declare @login_len int declare @db_len int select @login_len = datalength(@login) select @db_len = datalength(@database) raiserror(916, 16, -1, @login_len, @login, @db_len,@database) retur@n (1) end end select @database = db_name() EXEC @retcode = dbo.sp_helpdistributor @rpcsrvname = @dist_rpcname OUTPUT, @distribdb = @distribdb OUTPUT IF @@error <> 0 BEGIN @ RAISERROR (14071, 16, -1) return (1) END IF @retcode <> 0 OR @distribdb IS NULL OR @dist_rpcname IS NULL BEGIN RAISERROR (14071, 16, -1) return(1) END SELECT @distproc = RTRIM(@dist_rpcname) + '.'@ + RTRIM(@distribdb) + '.dbo.sp_MSpublication_access' declare @skip bit declare @login2 sysname if @reserved = 'init' begin -- Skip logins that are not at the distributor without -- raiseing error. set @skip = 1@ declare hC CURSOR LOCAL FAST_FORWARD for select loginname from master..syslogins where (is_srvrolemember('sysadmin', loginname) = 1 or sid = suser_sid()) for read only end else begin @set @skip = 0 declare hC CURSOR LOCAL FAST_FORWARD for select @login for read only end open hC fetch hC into @login2 while (@@fetch_status <> -1) begin EXEC @retcode = @distproc @ @publisher = @@SERVERNAME, @publisher_db = @database, @publication = @publication, @login= @login2, @operation = 'add', @skip = @skip IF @@error <> 0 OR @retcode <>@ 0 return (1) fetch hC into @login2 end close hC deallocate hC <. x5.x8L.x)|.lJP. x .4. xe6. V0. w@.0'^create procedure sp_MSenumpubreferences (@publication sysname) as declare @pubid uniqueidentifier declare @retcode int /* ** Security Check. */ exec @retcode = dbo.sp_MSreplcheck_publish if @@ERROR <> 0 or @retcode <> 0 return(1) if not exists (select * from sysobjects where name = 'sysmergepublications') BEGIN RAISERROR (20054, 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 BEGIN RAISERROR (20026, 16, -1, @publication) RETURN (1) END select distinct ReferencingObject = object_name(rkeyid), ArticleObject = object_name(fkeyid) from sysreferences r, sysmergearticles where r.fkeyid in (select objid from sysmergearticles where pubid = @pu@id) and r.rkeyid not in (select objid from sysmergearticles where pubid = @pubid) select distinct ReferencedObject = object_name(fkeyid), ArticleObject = object_name(rkeyid) from sysreferences r where r.rkeyid in (select objid from sysmergearticles where pubid = @pubid) and r.fkeyid not in (select objid from sysmergearticles where pubid = @pubid) return (0) lP. w .HP. w.P. w. P. w.4.we6.́CJ0**\* *)##d##"8h\<<\/6SplitNextD-, -m/ s@p_L-,ib 5vi/ X,.DE.x8Ty6 user_transaction .y'^t.yE. **'^publ ^t``4.y6.(@Q0D\(@publication-F-E0&p X0.@z6 grrev&L.zy .'^ P. z . 4.z6.dV0,0X,6p ,@subscriber_db-F-S0&p S@subscription_typesl-Pz .D c.(A``{6,sp_MSsubsetpublication.{F.G0&`G@publication`.{\.(6`(@publicationP.{ .` .{@`.{K.^0*`P 6 ^sp_MSsubsetpublicationt.{]-A :6`:sp_MSsubsetpublicationD.{Z.  `. {.Q0`Q create procedure sp_MSsubsetpublication (@publication sysname) as declare @pubi@ uniqueidentifier declare @false bit declare @true bit declare @boolean_filter bit declare @join_filter bit declare @full int declare @subset int declare @unsynced int /* ** Initializations */ select @true = 1 select @false = 0 select @full = 0 /* Const: publication type 'full' */ select @subset = 1 /* Const: publication type 'subset' */ select@@unsynced = 1 if not exists (select * from sysobjects where name = 'sysmergepublications') BEGIN RAISERROR (20054, 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 BEGIN RAISERROR (20026, 16, -1, @publication) RETURN (1) END /* ** Set the p@blication_type to subset if the publication has either a boolean or a join filter */ if exists (select * from sysmergearticles where pubid = @pubid and len(subset_filterclause) > 0) set @boolean_filter = @true if exists (select * from sysmergesubsetfilters where pubid = @pubid) set @join_filter = @true /* ** For subset publications set the article status to be unsynced so that the triggers can be regenerated. */ if (@boolean_filter = 1 OR @join_filter @ 1) begin update sysmergepublications set publication_type = @subset where pubid = @pubid if @@ERROR <> 0 return (1) update sysmergearticles set status = @unsynced where pubid = @pubid if @@ERROR <> 0 return (1) end else update sysmergepublications set publication_type = @full where pubid = @pubid if @@ERROR <> 0 return (1) return(0) P. {H .P. {. P. {. P. {. 4.{6.́CJ0( 8 \ <\ate-$F*-#[0&p @[@optional=u dX.DK.T|6 user_transaction .|`t.|K. **`/ ^`i4.|6.(@Q0D\/* @ L-)Gw L-*GPr . D c.(A\}r6(sp_MSindexcolfrombin|. }d ( C0&88 C@object_id\. }l.$6$@object_id|. }d . C0&88 C@col_@index\. }l. $6$@col_index. }d . E0&E@colids_binb`. }m. &6&@colids_bin x. }d . ?0&?@colnameX.  }n.  6@ @colnameP.  } ( dP.  } .  z,P.  } .  " .  }. }S(Z0*P r6 Zsp_MSindexcolfrombinp. }Y?. 66@sp_MSindexcolfrombinaD. }Z.  `. }#U.(0( create procedure sp_MSindexcolfrombin @object_id int, @col_index int, @colids_bin varbinary(256), @colname sysname output AS /* Declare variables */ declare @start_byte int declare @colid int set @colid = unicode( substring( convert( nvarchar(128),@coli@s_bin ), @col_index, 1 ) ) /* Use object id and colid to look up the column name in syscolumns */ select @colname = name from syscolumns where id = @object_id and colid = @colid return (0) P.  } .P.  }. P.  }.  P.  }. H4. }r6. ́CJ0 p p,(hHh 4\put_params N6%*@identity_col i6% *@include_type @6%@indent@s6% @is_new 36%@objid6%  @op_type6% @postfix6%@prefix 6% 6@primary_key_bitmapve6% $@set_nulls6%d6X .DS. T~6 user_transaction .~t.~S. **@s^ Z\_4.~6.(@Q0D\2@fk_table_cataloged62@fk_table_catalog 6,@fk_taP(%&.D c. (A \S6&sp_MSmakejoinfilterl.d.  G0&G@publication`..  (6(@publicationx.d.?0&?@@articleX.. 6 @article.d.E0&88 E@base_objid,`..&6&@base_objid.d.E0&88 E@join_objid`. .&@&@join_objid. d . G0&88 G@join_unique`. . (6(@join_uniqueP. * .  P. * . P.* .P.@* .P.* .P.* .P.0 .P.0 .C .4.S .X0*P @6 Xsp_MSmakejoinfilterl.YJ. 464sp_MSmakejoinfilterD.Z.  H/X6SplitNextD. . /n@tL.L.(@{L.( h..-0u-SQLTrace.dll <. .2x8L.).u sP.  . 4.X6.V0<..@0 create procedure sp_MSmakejoinfilter @publication sysname, @article sysname, @base_objid int, @join_objid int, @join_unique int AS /* Declare additional variables */ declare @@table_name sysname declare @join_table sysname declare @join_article sysname declare @filt_name sysname declare @basecol sysname declare @joincol sysname declare @keycnt int declare @@basekeys varbinary(32) declare @joinkeys varbinary(32) declare @keyindex int declare @filtclause nvarchar(3000) declare @filtpiece nvarchar(500) declare @qual_jointable nvarchar(258) declare@ @retcode smallint declare @pubid uniqueidentifier select @pubid = pubid from sysmergepublications where name = @publication and UPPER(publisher)=UPPER(@@SERVERNAME) and publisher_db=db_name() /* Are we adding join filt@er on referencing table (@join_unique = 1) or on unique key table ? */ if @join_unique = 1 /* Select the keycnt, fkeys, rkeys, and filter name from sysreferences */ select @keycnt = keycnt, @basekeys = forkeys, @joinkeys = refkeys, @filt@_name = object_name(constid) from sysreferences where fkeyid = @base_objid and rkeyid = @join_objid else select @keycnt = keycnt, @basekeys = refkeys, @joinkeys = forkeys, @filt_name = object_name(constid) from sysre@ferences where rkeyid = @base_objid and fkeyid = @join_objid /* Set up object names - we use them as correlation values */ set @table_name = QUOTENAME(object_name(@base_objid)) set @join_table = QUOTENAME(object_name(@join_objid)) @ select @join_article = name from sysmergearticles where objid = @join_objid and pubid=@pubid -- set @qual_jointable = @join_owner + '.' + @join_table /* Loop over keys, building up our join filter clause */ set @keyindex = 1 while @@keyindex <= @keycnt begin /* Get the column names */ exec dbo.sp_MSindexcolfrombin @base_objid, @keyindex, @basekeys, @basecol output if @@ERROR<>0 return (1) exec dbo.sp_MSindexcolfrombin @join_objid, @keyinde@x, @joinkeys, @joincol output if @@ERROR<>0 return (1) /* Make the piece of predicate pertaining to this key column */ set @filtpiece = @table_name + '.' + @basecol + ' = ' + @join_table + '.' + @joincol /* I@f first time through, initialize clause, else add to it */ if @keyindex = 1 set @filtclause = @filtpiece else set @filtclause = @filtclause + ' and ' + @filtpiece /* move on to the next key */ @ set @keyindex = @keyindex + 1 end /* Add the join filter */ exec @retcode = dbo.sp_addmergefilter @publication, @article, @filt_name, @join_article, @filtclause, @join_unique if @@ERROR<>0 or @retcode<>0 return (1) return (0H) )P.#  .!P.$ .$P.% .% P.& .&4.X6.́CJ0H%$$X$$ H X t 0 88HX(Hh8\ @nosync tinyint X6X&.#DS .hT6 user_transaction .#t.#S .# ** in XaZour4.#6.#(@Q0D\e DECLARE @platform_nt binary declare @is_jet int declare @Jet_datasource_path sysname P$-..$D c.(A D\96&sp_MSmakeexpandproc x.$d4. ?0& ?@pubnameiX.$q( 6  @pubname|.$d5.$A0& 88 A@filterid@t @\.$q.$"6 "@filterids |.$d6.$A0& A@procnameund\.$q.$"6 "@procnameriP.$s .  P.$ s .$  P.$ s .@  P.$ v .$  P.$ v .$   .$  4.$S.#X0* P 96 Xsp_MSmakeexpandprocl.$YI.46 4sp_MSmakeexpandprocD.$Z@.  H/96SplitNextD.$ ./tio@_tyL.$;:L.$;(:k_h L.$:( ;  .$.$Fw 0F-----------------------@---------------- -- NOTE: FOR INTERNAL SECURITY USE ONLY! -- DO NOT DOCUMENT OR USE! ---------------------------------------- create procedure sp_MSadduser_implicit_ntlogin @ntname sysname AS -- NO-OP IF LOGIN ALREADY EXISTS -- if user_id(@ntname) is null begin -- MUST BE NT NAME -- if (charindex('\', @ntname) = 0) return (1) declare @newsid varbinary(85), @status smallint, @uid smallint @-- OBTAIN NT SID FOR THIS USER (SET STATUS BITS) -- select @status = 4 -- ntlogin(4) select @newsid = get_sid('\U'+@ntname, NULL) -- NT user if (@newsid is Null) begin select @newsid = get_sid('\G'+@ntname, NULL) -- NT group IF (@newsid IS Null) return (1) end else select @status = @status | 8 -- NTUser -- FAIL IF SID ALREADY IN SYSUSERS -- if exists (select sid from sysusers where sid =@@newsid) return (1) -- OBTAIN NEW UID (RESERVE 1-4) -- if user_name(5) IS NULL select @uid = 5 else select @uid = min(uid)+1 from sysusers where uid >= 5 and uid < (16384 - 1) -- stay in users range and user_name(uid+1) is null -- uid not in use if @uid is null begin raiserror(15065,-1,-1) return (1) end -- ADD IMPLICIT SYSUSERS ENTRY -- insert@into sysusers values (@uid, @status, @ntname, @newsid, 0x00, getdate(), getdate(), 0, NULL) -- INVALIDATE UID CACHE FOR THIS DB -- grant all to null end -- RETURN FAILURE/SUCCESS -- return @@error -- sp_MSadduser_implicit_ntlogin (05w create proc sp_MSinit_replication_perfmon as declare @agent_type int declare @agent_name nvarchar(100) declare @status int -- Remove all existing instances dbcc deleteinstance (@SQL Replication Agents", "%") dbcc deleteinstance ("SQL Replication Snapshot", "%") dbcc deleteinstance ("SQL Replication Logreader", "%") dbcc deleteinstance ("SQL Replication Distribution", "%") dbcc deleteinstance ("SQL Replication Merge", "%") -- Add and initialize Perfmon SQL Replication Agents instances dbcc addinstance ("SQL Replication Agents", "Snapshot") dbcc addinstance ("SQL Replication Agents", "Logreader") dbcc addinstance ("SQL Replication Agents", "@istribution") dbcc addinstance ("SQL Replication Agents", "Merge") dbcc setinstance ("SQL Replication Agents", "Running", "Snapshot", 0) dbcc setinstance ("SQL Replication Agents", "Running", "Logreader", 0) dbcc setinstance ("SQL Replication Agents", "Running", "Distribution", 0) dbcc setinstance ("SQL Replication Agents", "Running", "Merge", 0) -- Add instances for each agent currently in the status table declare hC CURSOR LOCAL FAST_FORWARD for select agent_type, age@t_name, status from tempdb.dbo.MSreplication_agent_status for read only open hC fetch hC into @agent_type, @agent_name, @status while (@@fetch_status <> -1) begin if @agent_type = 1 begin dbcc addinstance ("SQL Replication Snapshot", @agent_name) if @status = 1 or @status = 3 or @status = 4 dbcc incrementinstance ("SQL Replication Agents", "Running", "Snapshot", 1) end else if @agent_type = 2 beg@n dbcc addinstance ("SQL Replication Logreader", @agent_name) if @status = 1 or @status = 3 or @status = 4 dbcc incrementinstance ("SQL Replication Agents", "Running", "Logreader", 1) end else if @agent_type = 3 begin dbcc addinstance ("SQL Replication Distribution", @agent_name) if @status = 1 or @status = 3 or @status = 4 dbcc incrementinstance ("SQL Replication Agents", "Running", "Distribut@on", 1) end else if @agent_type = 4 begin dbcc addinstance ("SQL Replication Merge", @agent_name) if @status = 1 or @status = 3 or @status = 4 dbcc incrementinstance ("SQL Replication Agents", "Running", "Merge", 1) end fetch hC into @agent_type, @agent_name, @status end close hC deallocate hC i<.$ ;.$x8L.$). @k:P.$  .'4.$96.$V0.$;.$0  create procedure sp_MSmakeexpandproc @pubname sysname, @filterid int, @procname sysname AS /* Declare additional variables */ declare @pubid uniqueidentifier declare @base_nick int declare @join_nick int decl@re @base_nickstr nvarchar(10) declare @join_nickstr nvarchar(10) declare @filterid_str nvarchar(10) declare @base_objid int declare @join_objid int declare @base_table sysname declare @join_table sysname declare @base_owner sysname declare @join_owner sysname declare @join_clause nvarchar(4000) declare @retcode int declare @must_check int declare @view_type int declare @guidcolname sysname declare @view_objid int declare @vie@_name sysname declare @cmd_piece nvarchar(4000) select @pubid = pubid from sysmergepublications where name = @pubname and UPPER(publisher)=UPPER(@@servername) and publisher_db=db_name() -- this procedure is to be called by xp_execresultset, so -- we create a temp table, put command pieces into it, and select them out -- create temp table to select the command text out of create table #tempcmd (step int identity NOT NULL, cmdtext nvarchar(4000) NULL) /* Figur@ out base table, join table for this join filter */ select @base_nick = art_nickname, @join_nick = join_nickname, @join_clause = join_filterclause from sysmergesubsetfilters where pubid = @pubid and join_filterid = @filterid select @base_objid = objid, @view_type = view_type, @view_objid = sync_objid from sysmergearticles where pubid = @pubid and nickname = @base_nick select @join_objid = objid from sysmergearticles where pubid = @pubid and nickname = @join_nick select@@base_table = QUOTENAME(name), @base_owner = QUOTENAME(user_name(uid)) from sysobjects where id = @base_objid select @join_table = QUOTENAME(name), @join_owner = QUOTENAME(user_name(uid)) from sysobjects where id = @join_objid select @guidcolname = name from syscolumns where id = @base_objid and columnproperty (id, name, 'isrowguidcol')=1 select @view_name = object_name(@view_objid) -- Quote the viewname. It is made from pub name which may have odd characters. set @v@ew_name = QUOTENAME(@view_name) set @base_nickstr = convert(nchar(10), @base_nick) set @join_nickstr = convert(nchar(10), @join_nick) set @filterid_str = convert(nchar(10), @filterid) set @cmd_piece = 'create procedure ' + @procname + ' @belong int AS ' insert into #tempcmd(cmdtext) values (@cmd_piece) set @cmd_piece = 'if @belong = 1 begin /* Do a bulk insert to expand #belong */ update #belong set@flag = ' + @filterid_str + ' where flag < ' + @filterid_str + ' insert into #belong (tablenick, rowguid, flag) select ' + @base_nickstr + ', ' + @base_table + '.rowguidcol, 0 from ' + @base_owner + '.' + @base_table + ', ' + @join_owner + '.' + @join_table + ', #belong b where (' + @join_clause + ') and ' + @join_table + '.rowguidcol = b.rowguid and b.tablenick = ' + @join_nickstr insert into #tempcmd(cmdtext) values (@cmd_piece) set @cmd_piec@ = ' if @@ERROR <>0 return (1) /* Delete duplicates */ delete from #belong where flag = 0 and rowguid in (select rowguid from #belong where flag <> 0) end ' insert into #tempcmd(cmdtext) values (@cmd_piece) /* Will we have to check rows that we add to #notbelong? */ if exists (select * from sysmergearticles where pubid = @pubid and nickname = @join_nick and len(subset_filterclause) > 0) set @must_check = 1 @ else if exists (select * from sysmergesubsetfilters where pubid = @pubid and join_filterid = @filterid and join_unique_key <> 1) 5) H/96SplitNextD.$ .$/ @ L.$0;L.$;.$heb_L.$ .$;26-1HL.$!).$  P.$"  .$4.$96.$V0,L,,+h++**lLp(xx(8`0\article IS NULL BEGIN RAISERROR (14043, 16, -1, '@article') RETURN (1) END if @article <> '%' BEGIN if NOT EXISTS (select * e i ewaiinD" -$P ..;x.$.$=0 = set @must_check = 1 else if not exists (select * from sysmergesubsetfilters where pubid = @pubid and art_nickname = @base_nick and join_filterid <> @filterid) set @must_check = 0 set @cmd_piece = ' else begin /* Do a bulk insert to expand #notbelong */ insert into #notbelong (tablenick, rowguid, flag) select ' + @base_nickstr@+ ', ' + @base_table + '.rowguidcol, -1 from ' + @base_owner + '.' + @base_table + ', ' + @join_owner + '.' + @join_table + ', #notbelong nb where (' + @join_clause + ') and ' + @join_table + '.rowguidcol = nb.rowguid /* Remove duplicates */ delete from #notbelong where flag = -1 and rowguid in (select rowguid from #notbelong where flag <> -1) ' if @must_check = 0 begin insert into #tempcm@(cmdtext) values (@cmd_piece) set @cmd_piece = ' update #notbelong set flag = 0 where flag = -1 end ' insert into #tempcmd(cmdtext) values (@cmd_piece) end else if @view_type = 1 begin insert into #tempcmd(cmdtext) values (@cmd_piece) set @cmd_piece = ' -- We can do our check with a bulk delete, bulk update delete from #notbelong where flag = -1 and rowguid in (select ' + @guidcolname + ' from ' + @v@ew_name + ') update #notbelong set flag = 0 where flag = -1 end ' insert into #tempcmd(cmdtext) values (@cmd_piece) end -- else we don't bother expanding #notbelong for this filter since there are cyclic -- join filters and this is not a unique key join. The cursored calls to sp_belongs -- are unacceptably slow, and there would still be cases where orphaned rows could occur. -- Now we select out the command text pieces in proper order so that o@r caller, -- xp_execresultset will execute the command that creates the stored procedure. select cmdtext from #tempcmd order by step 0 P.;  .$#P.; .;P.; .; P.; .;4.$96.$ H 0 rgesubscriptions */ INSERT sysmergesubscriptions (subid, partnerid, datasource_type, datasource_path, srvid, db_name, pubid, status, subscriber_type, uid X .ADS.$/T6 user_transaction .A t.AS.A **  X Z @4.A6.A(@Q0D\ @datasource_path, @subscriber_srvid, @subsPX*,.BD c.$(AD}7t6@sp_MSdrop_expired_mergesubscriptP.B .$ De P.B .BD((suP.B .BD( P.B .BD@ 0 and UPPER(datasource) = UPPER(@@servername))@ begin if exists (select * from tempdb..sysobjects where name = 'MSdistributor_access' and type = 'U') drop table tempdb.dbo.MSdistributor_access create table tempdb.dbo.MSdistributor_access ( spid int NOT NULL, db_id int not null, agent_id int not null, agent_type int not null, publication_id int not null, login_time datetime not null ) CREATE CLUSTERED INDEX ucMSdistributor_acc@ss ON tempdb.dbo.MSdistributor_access (spid, agent_id, db_id) end 0,7(server internal) <.B :.B: x8L.B).$"!meP.B  .;4.B 6.B V0.B :.B0D create procedure sp_M@drop_expired_mergesubscription AS /* ** This stored procedure is to periodically check the status of all the subscriptions ** of every merge publication. If any of them is out-of-date, i.e., has lost contact ** with publisher for a certain length of time, we can declare the death of that replica ** and cleanup their traces at the publisher side */ declare @subscription_type int declare @sub_type nvarchar(5) declare @publication sysname declare @pubid uniqueidentif@er declare @subid uniqueidentifier declare @status tinyint declare @publisher_id int declare @subscriber sysname declare @subscriber_id int declare @subscriber_db sysname declare @publisher_db sysname declare @distributor sysname declare @distribdb sysname declare @retention int -- in days declare @retcode smallint declare @distproc nvarchar(255) declare @localproc nvarchar(2@5) declare @msg nvarchar(255) declare @recgen int declare @sentgen int declare @max_distretention int declare @recent_merge datetime declare @minus_retention2 datetime declare @minus_retention datetime declare @send_ts datetime declare @receive_ts datetime /* ** Security Check */ EXEC @retcode = dbo.sp_MSreplcheck_publish IF @@ERROR <> 0 or @retcode <> 0 return (1) declare PC CURSOR LOCAL FAST_FORWA@D for select DISTINCT p.name, p.pubid, p.retention from sysmergepublications p, sysmergesubscriptions s where s.subid=p.pubid and s.pubid=p.pubid for read only open PC fetch PC into @publication, @pubid, @retention select @minus_retention2 = dateadd(day, -@retention * 2, getdate()) select @minus_retention = dateadd(day, -@retention, getdate()) WHILE (@@fetch_status <> -1) BEGIN if @retention is not NULL and @retention > 0 begin @ declare SC CURSOR LOCAL FAST_FORWARD for select srvid, db_name, subid, status, subscription_type from sysmergesubscriptions where pubid = @pubid and pubid<>subid for read only open SC fetch SC into @subscriber_id, @subscriber_db, @subid, @status, @subscription_type WHILE (@@fetch_status <> -1) BEGIN select @subscriber=srvname from master..sysservers where srvid=@subscriber_id i@ @subscription_type = 0 select @sub_type = 'push' else select @sub_type = 'pull' select @receive_ts = coldate from MSmerge_genhistory where guidsrc = (select recguid from MSmerge_replinfo where repid = @subid) select @sentgen=sentgen from MSmerge_replinfo where repid=@subid select @send_ts = coldate from MSmerge_genhistory where generation=@sentgen if @receive_ts>@send_ts select @recent_me@ge = @receive_ts else select @recent_merge = @send_ts if @status <> 2 and @recent_merge<@minus_retention begin exec @retcode = dbo.sp_dropmergesubscription @publication = @publication, @subscriber = @subscriber, @subscriber_db = @subscriber_db, @s@bscription_type = @sub_type if @retcode <>0 or @@ERROR<>0 goto FAILURE end if @recent_merge<@minus_retention2 begin delete from sysmergesubscriptions where subid = @subid --delete the row in sysmergesubscription if ERRt.B:.B90D9@@ERROR<>0 @ goto FAILURE delete from MSmerge_replinfo where repid = @subid if @@ERROR<>0 goto FAILURE end fetch SC i@nto @subscriber_id, @subscriber_db, @subid, @status, @subscription_type END CLOSE SC DEALLOCATE SC end fetch PC into @publication, @pubid, @retention END CLOSE PC DE@ALLOCATE PC return (0) FAILURE: close SC deallocate SC close PC deallocate PC return (1) P.B  .BP.B .BP.B .B 4.BH6.B ))P))#h <l0p \M -d x} -Md 4-M( f0*d P H6 fsp_changemergesubscriptioner|-MW-DB6d Bsp_changemergesubscription6D-Murf R5iSe n@se-B_X,.XDS.BT`6 user_transaction .XDt.XS.X **D xzL4.X`6.X(@Q0D\|-N|- @0z  create procedure sp_addlogin P.YD c.B(A}7[X6$sp_generatefilters.Y(G0&}7G@publicationu`.Yq".$(6}7(@publicationP.Y .B}7e 'sP.Y@ .Y}7 se .Y}7.YS.XV0*}7P 6 Vsp_generatefiltersL l.Y. 26}72sp_generatefilterse D.Y Z.B  }7H/6SplitNextD.Y  @B /dif@ereL.Y L.Y .B  L.Y(omr.4.Y.Y 0;create procedure sp_procedures_rowset;2 ( @procedure_schema sysname = null ) as select PROCEDURE_CATALOG = db_name(), PROCEDURE_SCHEMA = user_name(o.uid), @ PROCEDURE_NAME = convert(nvarchar(134),o.name +';'+ ltrim(str(p.number,5))), PROCEDURE_TYPE = convert(smallint, 3 /*DB_PT_FUNCTION*/), PROCEDURE_DEFINITION = convert(nvarchar(1),null), DESCRIPTION = convert(nvarchar(1),null), DATE_CREATED = o.crdate, DATE_MODIFIED = convert(datetime,null) from sysobjects o, syscomments p where permissions(o.id) <> 0 and (@procedure_schema is null or @procedure_schema = user_name(o.uid)) and o.type = 'P' /* Object type of Procedure */@ and p.colid = 1 and p.id = o.id order by 2, 3 I<.Y .Yx8L.Y).B;llP.Y  .B4.Y 6.Y V0.Y .Y0}7 create procedure sp_generatefilters @publication sysname AS /* Declare a few v@riables */ declare @pubid uniqueidentifier declare @art_name sysname declare @object_id int declare @join_objid int declare @retcode int declare @join_unique int declare @distance int /* ** Security Check */ EXEC @retcode = dbo.sp_MSreplcheck_publish IF @@ERROR <> 0 or @retcode <> 0 return (1) /* ** Parameter Check: @publication. ** The @publication id cannot be NULL and must conform to the rules ** for ident@fiers. */ if @publication is NULL begin raiserror (14043, 16, -1, '@publication') return (1) end /* ** Get the pubid and make sure the publication exists */ select @pubid = pubid from sysmergepublications where name = @publication and UPPER(publisher)=UPPER(@@servername) and publisher_db=db_name() if @pubid is NULL begin raiserror (14027, 16, -1, @publication) return (1) @ end /* Set up some temp tables to help keep track of what to process */ create table #filtered (object_id int NOT NULL, distance int NOT NULL) create table #unfiltered (object_id int NOT NULL, art_name sysname NOT NULL) /* Do initial population of temp tables */ insert into #filtered (object_id, distance) select objid, 0 from sysmergearticles where pubid = @pubid and len(subset_filterclause) > 0 insert into #unfiltered (object_id, art_name) select objid, n@me from sysmergearticles where pubid = @pubid and objid not in (select object_id from #filtered) /* remove self-referencing tables from #unfiltered as we should not try to filter them */ delete from #unfiltered where object_id in (select rkeyid from sysreferences where rkeyid = fkeyid) select @distance = min(distance) from #filtered f, sysreferences r, #unfiltered u where (f.object_id = r.rkeyid and r.fkeyid = u.object_id) or (u.object_id = r.rkeyid @nd r.fkeyid = f.object_id) /* Look for something in sysreferences to add a join filter for */ select @join_unique = 1, @object_id = fkeyid, @join_objid = rkeyid, @art_name = art_name from sysreferences r, #unfiltered u where r.fkeyid = u.object_id and r.rkeyid in (select object_id from #filtered where distance = @distance) if @art_name is null select @join_unique = 0, @object_id = rkeyid, @join_objid = fkeyid, @art_name = art_name from sy@references r, #unfiltered u where r.rkeyid = u.object_id and r.fkeyid in (select object_id from #filtered where distance = @distance) while @art_name is not null begin /* Make the join filter corresponding to this relationship */ exec @retcode=sp_MSmakejoinfilter @publication, @art_name, @object_id, @join_objid, @join_unique if @@ERROR<>0 or @retcode<>0 return (1) /* Move row from #unfiltered to #filtered */ insert into #filtered (obj@ct_id, distance) values (@object_id, @distance + 1) delete from #unfiltered where object_id = @object_id /* See if any more that can be added */ select @distance = min(distance) from #filtered f, sysreferences r, #unfiltered u where (f.object_id = r.rkeyid and r.fkeyid = u.object_id) or (u.object_id = r.rkeyid and r.fkeyid = f.object_id) set @art_name = NULL select @join_unique = 1, @object_id = fkeyid, @join_objid = rkeyid, @@rt_name = art_name from sysreferences r, #unfiltered u where r.fkeyid = u.object_id and r.rkeyid in (select object_id from #filtered where distance = @distance) if @art_name is null select @join_unique = 0, @object_id = rkeyid, @join_objid = fkeyid, @artnam.Y.Y0}7_name = art_name from sysreferences r, #unfilte@red u where r.rkeyid = u.object_id and r.fkeyid in (select object_id from #filtered where distance = @distance) end return (0) P.Y  .YP.Y .YP.Y H.Y P.Y .Y4.Y6.Y, j4D4D  t8l PT44\b_name() IF @pubid IS NULL BEGIN RAISERROR (20026, 11, -1, @publication) RETURN (1) END /* ** Validate that the publisher is a valid server */ select @publisher_srvid = srvid from master..aesaa ia .X.hDS.YTA6 user_transaction .h}7t.hS.h **}7ULL VEX 4.hA6.h(@Q0D\URN (1) END /* ** Validate that the subscriber is a valid server */ select @subscriber_srvid = sX0.i@6 grrevbeL.i .}7 P.i  .Y 4.i6.idV0#0XO/H6SplitNextD-! O-/ @ bL-"O}0|LP.jD c.Y(A[l"68sp_MShelpmergeconflictcounts.j.YQ0&[Q@publication_namel.jq2.Y26[2@publication_nameP.j ([@ .j[.jS$.hj0*[P "6 jsp_MShelpmergeconflictcounts.jY=.B F6[Fsp_MShelpmergeconflictcountsnD.jZ.Y  [.j #J0[ create procedure sp_MShel@mergeconflictcounts ( @publication_name sysname = '%' ) as begin set nocount on declare @pname sysname, @aname sysname, @cmd nvarchar(2000), @dbname sysname, @conflict_table sysname, @count integer, @db_mergepublish integer select @dbname = db_name(), @db_mergepublish = 4 -- make sure current db has merge publishing tables (true on both pub and sub) if not exists ( select * from sysobjects where name = 'sysmergearticles') begin raiserror( 18757, 16, -@ ) return(1) end -- allow null conflict table name to handle case where there are delete conflicts but no update conflicts create table #result_list ( article sysname, source_object sysname, conflict_table sysname null, guidcolname sysname, centralized_conflicts integer, conflicts_ucount integer, conflicts_dcount integer ) create table #conflict_list ( article_name sysname, conflicts_ucount integer, conflicts_dcount integer ) create table #update_list ( article_name sysname, conflicts_ucount@integer ) -- get delete counts if ( @publication_name = '%' ) declare hCdcount CURSOR LOCAL FAST_FORWARD fast_forward for select distinct a.name from MSmerge_delete_conflicts d inner join sysmergepublications p on p.pubid = d.pubid inner join sysmergearticles a on a.pubid = p.pubid and a.nickname = d.tablenick else declare hCdcount CURSOR LOCAL FAST_FORWARD fast_forward for select distinct a.name from MSmerge_delete_conflicts d inner join sysmergepublicati@ns p on p.pubid = d.pubid inner join sysmergearticles a on a.pubid = p.pubid and a.nickname = d.tablenick where p.name = @publication_name open hCdcount fetch hCdcount into @aname while ( @@fetch_status <> -1 ) begin select @cmd = 'select ''' + @aname + ''', 0, count(*) from MSmerge_delete_conflicts d inner join sysmergepublications p on p.pubid = d.pubid inner join sysmergearticles a on a.pubid = p.pubid and a.nickname = d.tablenick where a.name = N''' + @an@me + ''' ' if ( @publication_name <> '%' ) select @cmd = @cmd + ' and p.name = N''' + @publication_name + '''' insert #conflict_list ( article_name, conflicts_ucount, conflicts_dcount ) exec ( @cmd ) fetch hCdcount into @aname end close hCdcount deallocate hCdcount -- get update counts if ( @publication_name = '%' ) declare hCucount CURSOR LOCAL FAST_FORWARD fast_forward for select distinct a.name, a.conflict_table from sysmergepublications p inner join@sysmergearticles a on a.pubid = p.pubid where a.conflict_table is not null else declare hCucount CURSOR LOCAL FAST_FORWARD fast_forward for select distinct a.name, a.conflict_table from sysmergepublications p inner join sysmergearticles a on a.pubid = p.pubid where a.conflict_table is not null and p.name = @publication_name open hCucount fetch hCucount into @aname, @conflict_table while ( @@fetch_status <> -1 ) begin select @cmd = 'select ''' + @aname + ''', c@unt(*) from ' + QUOTENAME( @conflict_table ) + ' ct inner join sysmergepublications p on p.pubid = ct.pubid ' if ( @publication_name <> '%' ) select @cmd = @cmd + ' where p.name = N''' + @publication_name + '''' insert #update_list ( article_name, conflicts_ucount ) exec( @cmd ) fetch hCucount into @aname, @conflict_table end close hCucount deallocate hCucount update #conflict_list set conflicts_ucount = isnull( ul.conflicts_ucount, 0 ) from #conflict_list c@ inner join #update_list ul on ul.article_name = cl.article_name delete #update_list from #update_list ul inner join #conflict_list cl on ul.article_name = cl.article_name insert #conflict_list select *, 0 from #update_list where conflicts_ucount > 0 drop table #update_list select @cmd = 'select distinct t.article_name, '''' + quotename(user_name( o.uid )) + .j .j ]0[] ''.'' + quotename(o.n@ame) + '''',' + ' a.conflict_table, c.name, p.centralized_conflicts, t.conflicts_ucount, t.conflicts_dcount from #conflict_list t inner join sysmergearticles a on a.name = t.article_name inner join sysmergepublications p on p.pubid = a.pu@bid inner join sysobjects o on o.id = a.objid inner join syscolumns c on c.id = o.id and ColumnProperty (o.id, c.name, ''IsRowGuidCol'') = 1 where t.conflicts_ucount > 0 or t.conflicts_dcount > 0' insert #result_list exec ( @cmd ) @ if ( @@error <> 0 ) return (1) drop table #conflict_list select * from #result_list drop table #result_list return (0) end rviP.j  .iP.j .j P.j .j HP.j .j4.j'6.jtea`p T0T\erver */ select @subscriber_srvid = srvid from master..sysservers where UPPER(srvname) = UPPER(@subscriber) IF @subscriber_srvid IS NULL BEGIN RAISERROR (14010, 16, -1) RETURN (1) END /* ** Check to see if you have a local / global subscription onlo ao 1pX.xDS$.jTm6 user_transaction .x[t.xS$.x **[ jl4.xm6.x(@Q0D\ select @subid = subs1.subid, @pubid = pubs.pubid, /* identified from publication name */ @subscriber_typeX0.y@6 grrevsuL.y .i[ P.y  .j 4.y6.ydV0N0X.srvid = @publisher_srvid and subs2.db_name = @publisher_db and subs1.pubid = subs2.subid and subs2.pubid = pubs.pubid and pubs.name = @publication P.zD c.j(A(lN68sp_helpmergearticleconflicts.z'.jG0&G@publicationl`.zq;.j(6(@publicationP.z# .jA%, -P.@# .z. P.z# .z* P.z% .z *P.z% .z .z .z S+.xj0*P N6 jsp_helpmergearticleconflicts @z D.Y F6Fsp_helpmergearticleconflicts D.z Z.j  8 .z (  0 CREATE PROCEDURE sp_helpmergearticleconflicts( @publication sysname = '%' ) as set nocount on declare @publisher sysname declare @publisher_db sysname declare @pubid uniqueidentifier declare @cmd nvarchar(4000) declare @retcode int declare @nickname int declare @retcode2 int declare @name sysname declare @source_owner sysname declare @source_object sysname declare @conflict_table sysname declare @guidcolname sysname declare @centralized_conflicts int declare @objid int declare @command nvarchar(200) select @publisher = @@SERVERNAME select @publisher_db =db_name() if @publication <> '%' begin @ /* ** Parameter Check: @publication. ** Make sure that the publication exists. */ select @pubid = pubid from sysmergepublications where name = @publication if @pubid IS NULL BEGIN RAISERROR (20026, 16, -1, @publication) RETURN (1) END end create table #temp_conflict(article sysname, source_owner sysname, source_objec@ sysname, conflict_table sysname, guidcolname sysname, centralized_conflicts int) declare #cur_conflict cursor local for select name, objid, conflict_table, pubid, nickname from sysmergearticles where conflict_table is not NULL and pubid in (select pubid from sysmergepublications where name like @publication) for read only open #cur_conflict fetch #cur_conflict into @name, @objid, @conflict_table, @pubid, @nickname while (@@fetch_status <> -1) b@gin select @command = 'if exists (select * from ' + QUOTENAME(@conflict_table) + ') select @retcode2 = 1 else select @retcode2 = 0' EXEC @retcode = dbo.sp_executesql @command, N'@retcode2 int output', @retcode2 output if @retcode <>0 return (1) if @retcode2 = 1 begin select @source_owner = user_name(uid) from sysobjects where id = @objid select @source_object = object_name (@objid) select @guidcolname = name from syscolumns where id = @objid and ColumnProperty(@obj@d, name, 'IsRowGuidCol') = 1 select @centralized_conflicts = centralized_conflicts from sysmergepublications where pubid = @pubid insert into #temp_conflict values (@name, @source_owner, @source_object, @conflict_table, @guidcolname, @centralized_conflicts) end if EXISTS (select * from MSmerge_delete_conflicts where tablenick = @nickname) begin insert into #temp_conflict values (@name, @source_owner, @source_object, 'MSmerge_delete_conflicts', @guidcolname, @centralized_conf@icts) end fetch #cur_conflict into @name, @objid, @conflict_table, @pubid, @nickname end select * from #temp_conflict order by article drop table #temp_conflict close #cur_conflict deallocate #cur_conflict return(0) P.z  .yP.z .zP.z .z P.z H.z4.zN6.źCJ08H|X8HH\(36),@subid) + '''' + ',' + '''' + @value + '''' BEGIN TRANSACTION change_priority exec dbo.sp_MSchange_priority @subid, @value if @@ERRORliet @.zX.DS+.z T6 user_transaction .t.S+. **R<>0 j lco4.6.(@Q0D\NSACTION END /* ** Return succeed. Pt.D c.z(A(aw d/60sp_helpmergeconflictrows.1.zG0&(G@publication `.qE.z(6((@publication.2.M0&(@M@conflict_tableh.qE..6(.@conflict_table .(.S1.b0*(P /6 bsp_helpmergeconflictrowsPH//6SplitNextD.  .Y %/@L. !@YL. .z Y!P. .zL. Y.jx8!H.!. H>*2:<26B>$0(($"*6*84J$*$"0*804.<&**F":D@:`0>420J@868H446@<F8><JB:XV:0,406&Y>sp_helpmergesub@cription6Rsp_helpreplicationoptionla6|6$sp_helprole@50sp_helprolemember6,le(sp_helprotect69>(sp_helpserver6l$sp_helpsort62 m"sp_helpsql6>0*sp_helpsrvrole6526sp_helpsrvrolememberu60s*sp_helpstartup6Kģc8sp_helpsubscriberinfo69I=4sp_helpsubscription6"wJsp_helpsubscription_pro@ertiess6e5`f$sp_helptext6 *sp_helptrigger6YTg$sp_helpuser6["sp_indexes6$0sp_indexes_rowset6}Hh*sp_indexoption 6!nc8sp_isarticlecolbitset6+P0sp_IsMBCSLeadByte6b44sp_link_publication6~.sp_linkedservers@6(<sp_linkedservers_@owset6sp_MSaddanonymousreplicaf6V B4sp_MSaddexecarticle6#Ft2sp_MSaddguidcolumn6\ju0sp_MSaddguidindex61oVJsp_MSaddlogin_implicit_ntlogin6@sp_MSaddmergepub_snapsh@t6g:|8sp_MSaddmergetriggers6[P6sp_MSaddpub_snapshot6CF{8sp_MSaddupdatetrigger6Hsp_MSadduser_implicit_ntlogin6 4sp_MSarticlecleanup6Y1?4sp_MSarticletextcol6x}6sp_MSchange_prioritys6C@sp_MScheck_agent_instance6a<sp_MScheck_subs@ription6!Fsp_MScheck_uid_owns_anything68sp_MScheckatpublisher6U>sp_MScheckvalidsystables6vo<sp_MScreate_dist_tables65&YJsp_MScreate_distributor_tablesRN6rWBsp_MScreate_mergesystables6/:sp_MScreate_pub_tables 6jXsp_MScreate_r@plication_checkup_agent6 Vsp_MScreate_replication_status_table65:sp_MScreate_sub_tables6;0sp_MSdbuseraccess6_,sp_MSdbuserpriv67\4sp_MSdeletecontents<. H. !Hx8x.) @6!@sp_helpmergesubscrip@ionP. . 4. /6. V0Hx.E.>6(>sp_helpmergeconflictrowstyD.Z.z  (.<(0(CREATE PROCEDURE sp_helpmergeconflictrows( @publication sysname = '%', @conflict_table sysname@ ) as set nocount on declare @publisher sysname declare @publisher_db sysname declare @pubid uniqueidentifier declare @cmd nvarchar(4000) select @publisher = @@SERVERNAME select @publisher_db = db_name() select @cmd = 'select * from ' select @cmd = @cmd + @conflict_table if @publication <> '%' begin /* ** Parameter Check: @publication. ** Make sure that the publication @xists. */ select @pubid = pubid from sysmergepublications where name = @publication if @pubid IS NULL BEGIN RAISERROR (20026, 16, -1, @publication) RETURN (1) END select @cmd = @cmd + ' where pubid = (select pubid from sysmergepublications where name = ''' + @publication + ''') ' end exec (@cmd) if (@@error <> 0) RETURNH(1) return 0 tcP.  .P. .P. .4./6.x8x8 lHXT p$L(@\* 2 both */ if LOWER(@subscription_type) NOT IN ('push', 'pull', 'both') BEGIN e tecourp6sX.DS1.Tz6 user_transaction .(t.S1. **(er hec bld *4.z6.(@Q0D\ IF @publisher <> '%' BEGIN EXECUTE @retcode = dbo.sp_validname @publisher IF @@ERROR <> 0 OR @retcodPn.D c.(Aaw k!p6<sp_helpmergedeleteconflictrows.(G0&aw G@publicationT`.qQ.(6aw (@publication..K0&aw @K@source_objectrd.qR.,6aw ,@source_objectP.I .z aw ix i .aw .S8.n0*aw P 6 nsp_helpmergedeleteconflictrowscr. F.J6aw Jsp_help@ergedeleteconflictrows D. Z. aw d . (* 0aw * CREATE PROCEDURE sp_helpmergedeleteconflictrows( @publication sysname = '%', @source_object nvarchar(386) = NULL ) as declare @publisher sysname declare @publisher_db sysname declare @pubid uniqueidentifier declare @cmd nvarchar(4000) select@@publisher = @@SERVERNAME select @publisher_db = db_name() select @cmd = 'select distinct source_object = user_name(sysobjects.uid) + ' select @cmd = @cmd + '''.''' select @cmd = @cmd + ' + sysobjects.name, MSmerge_delete_conflicts.rowguid, MSmerge_delete_conflicts.conflict_type, ' select @cmd = @cmd + ' MSmerge_delete_conflicts.reason_code, MSmerge_delete_conflicts.reason_text, ' select @cmd = @cmd + ' MSmerge_delete_conflicts.origin_datasource, MSmerge_delete_conflicts.pubi@ from MSmerge_delete_conflicts, sysmergearticles, sysobjects' select @cmd = @cmd + ' where sysmergearticles.nickname = MSmerge_delete_conflicts.tablenick and sysobjects.id = sysmergearticles.objid ' if @publication <> '%' begin /* ** Parameter Check: @publication. ** Make sure that the publication exists. */ select @pubid = pubid from sysmergepublications where name = @publication if @pubid@IS NULL BEGIN RAISERROR (20026, 16, -1, @publication) RETURN (1) END select @cmd = @cmd + ' and MSmerge_delete_conflicts.pubid = (select pubid from sysmergepublications where name = ''' + @publication + ''') ' end if @source_object IS NOT NULL begin declare @object sysname declare @owner sysname declare @tab@enick int declare @tablenickstr nvarchar(11) select @object = PARSENAME(@source_object, 1) select @owner = PARSENAME(@source_object, 2) execute dbo.sp_MStablenickname @owner, @object, @tablenick output if @tablenick IS NULL BEGIN raiserror (20003, 11, -1, @object) RETURN (1) END set @tablenickstr = convert(nchar, @tablenick) @ select @cmd = @cmd + ' and MSmerge_delete_conflicts.tablenick = ' select @cmd = @cmd + @tablenickstr end exec (@cmd) if (@@error <> 0) RETURN (1) return 0 P.  .P. . P. . P. .H4.6.́CJ0x(t00L\ sysmergesubscriptions subs2, MSmerge_replinfo replinfo, master..sysservers servers1, master..sysservers servers2, sysmergepublications pubs where subs1.subid <> subs2.subid and subs1.status <> 2 l d mX.DS8. T[6 user_transaction .aw t.S8. **aw bliati n p 4.[6.(@Q0D\ and (suser_sname(suser_sid()) = subs1.login_name OR is_member('db_owner')=1 OR is_srvrolemember('sysadmin') = 1) P"0'(.D c.(Ak!`"h62sp_deletemergeconflictrowe)..M0&k!M@conflict_table h.qX..6k!.@conflict_tableEL. .K0&k!@K@source_objectmd.qY.,6k!,@source_objectx. .?0&k!$$?@rowguid X.qY. 6k! @rowguid. .S0&k!S@origin_datasourcel.@ qY.46k!4@origin_datasource.  . W0&k! W@drop_table_if_empty p. qY. 86k!8@drop_table_if_emptyP. ^ .k!ixubs . k!.S>.@d0*k!P 6 dsp_deletemergeconflictrowx. .. @6k!@sp_deletemergeconflictrowD.Z .  k!H/6SplitNext8..V0L. . /D.@ ./she@)))8. .x8L.L.(  L.(goE L.).Yk!= P.  .4.@6.V0P..0k! CREATE PROCEDURE sp_deletemergeconflictrow( @conflict_table sysname = '%', @source_object nvarchar(386) = NULL, @rowguid uniqueidentifier, @orig@in_datasource varchar(255), @drop_table_if_empty varchar(10) = 'false') as declare @retcode smallint declare @cmd nvarchar(4000) declare @rowguidstr nvarchar(40) declare @object sysname @ declare @owner sysname declare @tablenick int declare @tablenickstr nvarchar(11) set @rowguidstr = convert(nchar(36), @rowguid) /* Delete conflict from Conflict_<Table> */ if @conflict_table <> '%' @ begin select @cmd = 'delete from ' select @cmd = @cmd + @conflict_table select @cmd = @cmd + ' where origin_datasource = ''' select @cmd = @cmd + @origin_datasource select @cmd = @cmd + @''' and rowguid = ''' select @cmd = @cmd + @rowguidstr select @cmd = @cmd + '''' -- DEBUG select 'Delete conflict_table query' = @cmd exec (@cmd) if @@ERROR<>0 return (1) selec@t @cmd = 'if not exists (select 1 from ' select @cmd = @cmd + @conflict_table select @cmd = @cmd + ')' select @cmd = @cmd + ' update sysmergearticles set ins_conflict_proc = NULL, conflict_table = NULL where conflic@t_table = ''' select @cmd = @cmd + @conflict_table select @cmd = @cmd + '''' -- DEBUG select "Update conflict_table query" = @cmd exec (@cmd) if @@ERROR<>0 return (1) if LOWER(@@drop_table_if_empty) = 'true' begin select @cmd = 'if not exists (select 1 from ' select @cmd = @cmd + @conflict_table select @cmd = @cmd + ')' select @@cmd = @cmd + ' drop table ' select @cmd = @cmd + @conflict_table select @cmd = @cmd + '' -- DEBUG select "Drop conflict_table query" = @cmd exec (@cmd) @ if @@ERROR<>0 return (1) end end /* Delete conflict from MSmerge_delete_conflicts */ else begin select @object = PARSENAME(@source_object, 1) select @owner = PARSENAME(@source_object, @2) execute @retcode=sp_MStablenickname @owner, @object, @tablenick output if @tablenick IS NULL or @@ERROR<>0 or @retcode<>0 BEGIN raiserror (20003, 11, -1, @object) @ RETURN (1) END set @tablenickstr = convert(nchar, @tablenick) select @cmd = 'delete from MSmerge_delete_conflicts' select @cmd = @cmd + ' where origin_datasource = ''' @ select @cmd = @cmd + @origin_datasource select @cmd = @cmd + ''' and tablenick = ' select @cmd = @cmd + @tablenickstr select @cmd = @cmd + ' and rowguid = ''' select @cmd = @cmd + @rowguidstr @ select @cmd = @cmd + '''' -- DEBUG select 'MSMerge_Delete conflict_table query' = @cmd exec (@cmd) if @@ERROR<>0 return (1) end P.  .P. .HP. . P. . 4.6.́CJ0&h&&%x%( X t<t,pddl8L\h0hggaQ|Q,QPGGXGG,766H6655H55%$$@$$|\d dclcc(VUUXU UTtT./T<6 user_transaction .k!t.S>. **k! @s def sy4.<6.(@Q0D\bscription_type nvarchar(15) = 'push', /* Subscription type - push, pull, both */ @ignore_distributor bit = 0P6 .D c.(A`" 5T#`6*sp_getmergedeletetype .. K0&`"K@source_objected.qj. ,6`",@source_objectx..?0&`"$$@?@rowguidsX.qj. 6`" @rowguid..G0&`"88 G@delete_typee`.qj.(6`"(@delete_typeP.o . `"ix . `". SE.\0*@`"P 6 \sp_getmergedeletetypep. . 86`"8sp_getmergedeletetypeD. Z. `". >(U0`"U CREATE PROCEDURE sp_getmergedeletetype( @source_object nvarchar (386), @rowguid uniqueidentifier, @delete_type int OUTPUT ) as decla@e @object sysname declare @owner sysname declare @tablenick int select @object = PARSENAME(@source_object, 1) select @owner = PARSENAME(@source_object, 2) execute dbo.sp_MStablenickname @owner, @object, @tablenick output if @tablenick IS NULL OR @@ERROR<>0 BEGIN raiserror (20003, 11, -1, @object) RETURN (1) END if @rowguid IS NULL begin raiserror (14027, 11, -1, '@rowguid') @ return (1) end select @delete_type = type from MSmerge_tombstone where rowguid = @rowguid and tablenick = @tablenick P.  .!P. .P. . P. .4.6.H́CJ0 <  XTt@\lication, @subscriber = @subscriber, @subscriber_db = @subscriber_db, @subscription_type = 'push', @ignore_distributor = @ignore_distributor, @reserved = 1 EXECUTE dbo.sp_dropmergesubscription @publication = @publication, @subscriber = @subscriber, rX .DSE. T6 user_transaction .`"t.SE. **`"on_ype \ ^ 4.6.(@Q0D\ter validation (different for push and pull modes) */ IF LOWER(@subscription_type) = 'push' begin P".D c.(A 5T#EYH$\6&sp_mergedummyupdatehe. .K0& 5T#K@source_object d.qp.,6 5T#,@source_objectx.!.?0& 5T#$$@?@rowguid X.qp. 6 5T# @rowguidP.| .  5T#ix . 5T#.SK.X0* 5T#P 6 Xsp_mergedummyupdatel. !$.46 5T#4sp_mergedummyupdateD. Z@   5T#l. E#l 40 5T#4 CREATE PROCEDURE sp_mergedummyupdate( @source_object nvarchar (386), @rowguid uniqueidentifier ) as declare @object sysname declare @owner sysname declare @tablenick int declare @tablenickstr nvarchar(11) select @object = PARSENAME(@source_object, 1) select @owner = PARSENAME(@source_object, 2) execute dbo.sp_MStab@enickname @owner, @object, @tablenick output if @tablenick IS NULL or @@ERROR<>0 BEGIN raiserror (20003, 11, -1, @object) RETURN (1) END set @tablenickstr = convert(nchar, @tablenick) declare @rowguidstr nvarchar(40) if @rowguid IS NULL begin raiserror (14043, 11, -1, '@rowguid') return (1) end set @rowguidstr = convert(nchar(36), @rowguid) /* ** If the row does not exist in the @ase table, call sp_MSdummyupdate with metadata_type = 1 (tombstone) */ exec ('if not exists (select 1 from ' + @source_object + ' where rowguidcol = ''' + @rowguidstr + ''' ) exec dbo.sp_MSdummyupdate ''' + @rowguidstr + ''',' + @tablenickstr + ', 1') /* ** If the row exists in the base table and MSmerge_contents , call sp_MSdummyupdate with metadata_type = 2 (contents) */ exec ('if exists (select 1 from ' + @source_object + ' where rowguidcol = ''' + @row@uidstr + ''' ) and exists (select rowguid from MSmerge_contents where rowguid = ''' + @rowguidstr + ''' ) exec dbo.sp_MSdummyupdate ''' + @rowguidstr + ''',' + @tablenickstr + ', 2') /* ** If the row exists in the base table, but not in MSmerge_contents , call sp_MSdummyupdate with metadata_type = 3 (contents_deferred) */ exec ('if exists (select 1 from ' + @source_object + ' where rowguidcol = ''' + @rowguidstr + ''' ) and not exists (select rowguid from MSmerge_co@tents where rowguid = ''' + @rowguidstr + ''' ) exec dbo.sp_MSdummyupdate ''' + @rowguidstr + ''',' + @tablenickstr + ', 3') P.  .P. . P. . P. .4.6.́CJ0H | , pp<\nd UPPER(publisher)=UPPER(@@servername) and publisher_db=db_name() set @pubidstr = '''' + convert(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 &  ngbl.X.DSK. T6 user_transaction . 5T#t.SK. ** 5T# XZ4.6.(@Q0D\Z.I _ 0) as t where (@table_schema is null or @table_schema = TABLE_SCHEMA) and (@table_type is null or @table_type = TABLE_TYPE) order by 4, 2, 3 0]($create procedure sp_tables_info_rowset;2 ( @table_schema sysname = null, @table_type nvarchar(255) = null ) as select * from (select TABLE_CATALOG = db_name(), TABLE_SCHEMA = user_name(o.uid), TABLE_NAME = o.name, @TABLE_TYPE = convert(nvarchar(30), case o.type when 'U' then case when ObjectProperty(o.id, 'IsMSShipped') = 0 then N'TABLE' else N'SYSTEM TABLE' end when 'S' then N'SYSTEM TABLE' when 'V' then case when ObjectProperty(o.id, 'IsMSShipped') = 0 then N'VIEW' else N'SYSTEM VIEW' end end), TABLE_GUID = convert(uniqueidentifier, null), BOOKMARKS = convert(bit, 1), BOOKMARK_TYPE = convert(int, 1 /*DBPROPVAL@BMK_NUMERIC*/), BOOKMARK_DATATYPE = convert(smallint, 19 /*DBTYPE_UI4 */), BOOKMARK_MAXIMUM_LENGTH = convert(int, 4), BOOKMARK_INFORMATION = convert(int, 0), TABLE_VERSION = convert(int, o.schema_ver), CARDINALITY = x.rows, DESCRIPTION = convert(nvarchar(1), null), TABLE_PROPID = convert(int, null) from sysobjects o left join sysindexes x on o.id = x.id and x.indid in (0,1) where o.type in ('U','V','S') and permissions(o.id) <> 0) as t where (@table_schema@is null or @table_schema = TABLE_SCHEMA) and (@table_type is null or @table_type = TABLE_TYPE) order by 4, 2, 3 u0g]$1create procedure sp_droprole @rolename sysname -- role to be dropped as -- SETUP RUNTIME OPTIONS / DECLARE VARIABLES -- set nocount on declare @uid smallint, @owner sysname, @ret int -- DISALLOW USER TRANSACTION -- set implicit_transactions off if (@@trancount > 0) begin raiserror(150@2,-1,-1,'sp_addrole') return (1) end -- ROLE NAME (OBTAIN OWNER FOR PERMISSIONS) -- select @uid = uid, @owner = user_name(altuid) from sysusers where name = @rolename and issqlrole = 1 -- CHECK PERMISSIONS -- if (not is_member('db_securityadmin') = 1) and (not is_member('db_owner') = 1) and (@owner is NULL or not is_member(@owner) = 1) begin raiserror(15000,-1,-1) return (1) end -- ERROR IF ROLE NOT FOUND -- if @uid is null @ begin raiserror(15014,-1,-1,@rolename) return (1) end -- ERROR IF FIXED ROLE or PUBLIC ROLE-- if @uid < 16400 or @uid = 0 begin raiserror(15142,-1,-1, @rolename) return (1) end -- ERROR IF ANYONE IS MEMBER OF ROLE (DISPLAYS MEMBERS) -- if exists (select * from sysmembers where groupuid = @uid) begin raiserror(15144,-1,-1) select name = user_name(memberuid) from sysmembers where groupuid = @uid return (1) end @ -- CHECK IF ROLE OWNS ANYTHING -- execute @ret = sp_MScheck_uid_owns_anything @uid if @ret <> 0 return (1) -- DROP SYSUSERS AND PROTECTION ENTRIES -- delete from syspermissions where grantee = @uid delete from sysusers where uid = @uid -- FINALIZATION: PRINT/RETURN SUCCESS -- if @@error <> 0 return (1) raiserror(15493,-1,-1) return (0) -- sp_droprole tri0oc}$Kreplcmds extended procedure <.@ @.x8L.).]($ P.  .4.6.V0..0EYH$ create procedure sp_addtabletocontents (@table_name sysname, @owner_name sysname = NULL) AS declare @qualified_table_name nvarchar(268) declare @tab@enick int declare @tablenickstr nvarchar(12) declare @repl_nick int declare @lineage varbinary(249) declare @colv varbinary(2000) declare @coltrack int declare @objid int declare @maxcolid int declare @retcode int declare @gen int set nocount on create table #temp_cont(rowguid uniqueidentifier) execute @retcode = dbo.sp_MSgetreplnick @nickname = @repl_nick output if (@@error <> 0) or @retcode <> 0 or @repl_nick IS NULL begin @ RAISERROR (14055, 11, -1) RETURN(1) end if @owner_name is NULL begin select @owner_name = user_name(uid) from sysobjects where name = @table_name end set @qualified_table_name = QUOTENAME(@owner_name) + '.' + QUOTENAME(@table_name) set @objid = object_id(@qualified_table_name) if @objid is NULL return (1) select @gen = max(gen_cur), @tablenick = max(nickname), @coltrack = max(column_tracking) from sysmergearticles where objid = @obj@d if @gen is null set @gen = 0 select @maxcolid = max(colid) from syscolumns where id = @objid if @coltrack = 1 set @colv = { fn INITCOLVS(@maxcolid, @repl_nick) } else set @colv = NULL set @lineage = { fn UPDATELINEAGE(0x0, @repl_nick) } set @tablenickstr = convert(nchar, @tablenick) exec ('insert into #temp_cont(rowguid) select RowGuidCol from ' + @qualified_table_name + ' where RowGuidCol not in (select rowguid from MSmerge_contents where@tablenick = ' + @tablenickstr + ')') insert into MSmerge_contents (tablenick, rowguid, generation, joinchangegen, lineage, colv1) select @tablenick, rowguid, @gen, @gen, @lineage, @colv from #temp_cont drop table #temp_cont :P.  .P. .P. . P.H .4.6.́CJ0H$##X##4Lt0, l|<\ /* ** Set back original settings */ IF @reserved = 0 BEGIN IF @implicit_transaction <>0 SET IMPLICIT_TRANSACTIONS ON IF @close_c i l 0 _ (eeX&.DSR. x8T6 user_transaction .EYH$t.SR. **EYH$P \^4.6.(@Q0D\P X.P4.IX6.IORCX0.@*6 grrevnyL. .yEYH$ P.  . 4.*6.dV0"0Xallow_pull int NOT NULL, allow_anonymous int NOT NULL, centralized_conflicts int EFo@bien mrss_ Tc0 Esrti P.D c.(A~}<%0&`6*sp_MSaddpubtocontents.2.G0&~}<%G@publication`.q.(6~}<%(@publicationP. . ~}<% atP.@ .~}<%P. .~}<%EYH$ .~}<%.(\0*~}<%P 6 \sp_MSaddpubtocontentsp. !5. 86~}<%8sp_MSaddpubtocontentsD. Z$. ~}<%H@/6SplitNextD.  ./@L. ?AL.?.AL.A(#? ..M7-0q%Mreplflush extended procedurere0A%@7(server internal)0ґ% -- Called by the UI to find out if the distributor is installed without doing RPC. CREATE PROCEDURE sp_get_distributor AS SET NOCOUNT ON /* ** Declarations. */ DECLARE @distributor sysname DECLARE @installed bit declare @distdb_installed bit declare @is_distpublisher bit declare @has_remote_distpublisher bit declare @distbit int SELECT @distbit = 16 SELECT @distributor = datasource FROM@master..sysservers WHERE srvstatus & 8 <> 0 if @distributor is not null select @installed = 1 else select @installed = 0 if UPPER(@distributor) = UPPER(@@servername) begin if exists (select * from msdb.dbo.MSdistributiondbs) select @distdb_installed = 1 else select @distdb_installed = 0 if exists (select * from msdb..MSdistpublishers where UPPER(name) = UPPER(@@servername)) select @is_distpublisher = 1 else select @is_distpublisher = 0 if exists (sel@ct * from msdb..MSdistpublishers where UPPER(name) <> UPPER(@@servername)) select @has_remote_distpublisher = 1 else select @has_remote_distpublisher = 0 end else begin select @distdb_installed = 0 select @has_remote_distpublisher = 0 select @is_distpublisher = 0 end select 'installed' = @installed, 'distribution server' = @distributor, 'distribution db installed' = @distdb_installed, 'is distribution publisher' = @is_distpublisher, 'has remote distribution publ@sher' = @has_remote_distpublisher 0%-SQLTrace.dll0&& /* Procedure for 7.00 server */ create procedure sp_table_constraints_rowset ( @table_name sysname, @table_schema sysname = null, @table_catalog sysname = null, @constraint_name sysname = null, @constraint_schema sysname = null, @constraint_catalog sysname = null, @constraint_type nvarchar(255) = null ) as select CONSTRAINT_CATALOG = db_name(), CONSTRAINT_SCHEMA = user@name(c_obj.uid), CONSTRAINT_NAME = c_obj.name, TABLE_CATALOG = db_name(), TABLE_SCHEMA = user_name(t_obj.uid), TABLE_NAME = t_obj.name, CONSTRAINT_TYPE = case (c.status & 0xf) when 1 then N'PRIMARY KEY' when 2 then N'UNIQUE' when 3 then N'FOREIGN KEY' when 4 then N'CHECK' end, IS_DEFERRABLE = convert(bit, 0), INITIALLY_DEFERRED = convert(bit, 0), DESCRIPTION = convert(nvarchar(1), null) from sysobjects c_obj, sysobjects@t_obj, sysconstraints c where t_obj.name = @table_name and t_obj.type in ('U','S') and (@table_catalog is null or @table_catalog = db_name()) and (@table_schema is null or @table_schema = user_name(t_obj.uid)) and c.id = t_obj.id and (c.status & 0xf) between 1 and 4 and c_obj.id = c.constid and c_obj.uid = user_id() and (@constraint_name is null or c_obj.name = @constraint_name) and (@constraint_catalog is null or @constraint_catalog = db_name()) and (@constraint_sche@a is null or @constraint_schema = user_name(c_obj.uid)) and (@constraint_type is null or (c.status & 0xf) = case @constraint_type when N'PRIMARY KEY' then 1 when N'UNIQUE' then 2 when N'FOREIGN KEY' then 3 when N'CHECK' then 4 end) order by 2,3,5,6,7 <. ?. x8L.).q% NP.  .@4. 6. V0. ?.0~}<% create procedure sp_MSaddpubtocontents (@publication sysname) AS declare @pubid uniqueidentifier declare @tablenick int declare @retcode int declare @objid int declare @owner sysname declare @table sysname set nocount on select @pubid = pubid from sysmergepublications where name = @publication and UPPER(pub@isher)=UPPER(@@servername) and publisher_db=db_name() if @pubid is NULL begin raiserror (14027, 11, -1, @publication) return (1) end select @tablenick = min(nickname) from sysmergearticles where pubid = @pubid while @tablenick is not null begin select @objid = objid from sysmergearticles where pubid = @pubid and nickname = @tablenick select @owner = user_name(uid) from sysobjects where id = @objid set @table = OBJECT_N@ME(@objid) exec @retcode = dbo.sp_addtabletocontents @table, @owner IF @@ERROR <> 0 or @retcode <> 0 return (1) select @tablenick = min(nickname) from sysmergearticles where pubid = @pubid and nickname > @tablenick end P.  .P. .P. .H P. .4.6.́CJ0l|,8h,d<@<<\ goto FAILURE end END END return 0 FAILURE: return (1) P.x ^ .xP.x ^Alm _ie X.D. x8T 6 user_transaction .~}<%t.. **~}<%  \^4. 6.(@Q0D\MtQL-9't@-.e b O mmX0.@V6 grrevL. .~}<% P.  . 4.V6.dV0"0X XfZ th4.`6.(@Q0D\er than sampling @norecompute CHAR(12)= 'NO' -- Optional 'NORECOMPUTE' text - if present, then statistics -- wilXz.`-66,sp_enumcustomresolvers.ac).xG0&ф5G@distributore`.awM.x(6ф5(@distributorP.aG (Lф5W`mbe .aX..J6.dq  t.a.):6ф5:sp_enumcustomresolverse D.aZ.x ф5Hb/6SplitNextD.  b.x/ DE@LARL. bXz.`.X6REL. b(LTISO.b. 0@create procedure sp_columns_rowset;5 ( @table_server sysname, @table_catalog sysname = null, @table_name sysname = null, @table_schema sysname = null, @column_name sysname = null ) as select TABLE_CATALOG,X..X6.d\0q  IS_NULLABLE, DATA_TYPE, TYPE_GUID, CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH, NUMERIC_PRECISION, NUMERIC_SCALE, DATETIME_PRECISION, CHARACTER_SET_CATALOG, CHARACTER_SET_SCHEMA, CHARACTER_SET_NAME, COLLATION_CATALOG, COLLATION_SCHEMA, COLLATION_NAME, DOMAIN_CATALOG, DOMAIN_SCHEMA, DOMAIN_NAMEX.<x8>6DMLbl4.>6. [00Tolumn_name > order by 1, 2, 3, 7 -<. b. x8L.b)b.x@E P. b .x4. b6. V0t. a.;0ф5P .D c.(A0&$'X6"sp_MSdrop_rlreconCOP. .0&t P. .0&ret .0&4. .T0*0&P 6 Tsp_MSdrop_rlrecon@h.Y .060&0sp_MSdrop_rlreconD.Z+.  0&.A.00&create procedure sp_MSdrop_rlrecon as if exists (select * from sysobjects where type = 'P' and name = 'sp_MSaddinitialpublication') drop procedure sp_MSaddinitialpublication -- **************************************************** -- THIS COMMENTED@CODE SECTION WILL BE DELETED SOON -- sp_MSgetversion is now part of XPSTAR.DLL and -- will not be installed by REPL code -- If sp_MSgetversion exists as SP drop it -- otherwise drop the extended proc /* if exists (select * from sysobjects where type = 'P' and name = 'sp_MSgetversion') drop procedure sp_MSgetversion else if exists (select * from sysobjects where type = 'X' and name = 'sp_MSgetversion') execute dbo.sp_dropextendedproc 'sp_MSgetversion' */ -- ****************@*********************************** if exists (select * from sysobjects where type = 'P' and name = 'sp_MSaddinitialsubscription') drop procedure sp_MSaddinitialsubscription if exists (select * from sysobjects where type = 'P' and name = 'sp_MSdropconstraints') drop procedure sp_MSdropconstraints if exists (select * from sysobjects where type = 'P' and name = 'sp_MSmakeinsertproc') drop procedure sp_MSmakeinsertproc if exists (select * from sysobjects whe@e type = 'P' and name = 'sp_MSmakeupdateproc') drop procedure sp_MSmakeupdateproc if exists (select * from sysobjects where type = 'P' and name = 'sp_MSmakeselectproc') drop procedure sp_MSmakeselectproc if exists (select * from sysobjects where type = 'P ' and name = 'sp_MSinsertschemachange') drop procedure sp_MSinsertschemachange if exists (select * from sysobjects where type = 'P' and name = 'sp_MSaddinitialarticle') drop procedure sp_MSaddinitialarti@le if exists (select * from sysobjects where type = 'P' and name = 'sp_MSmakearticleprocs') drop procedure sp_MSmakearticleprocs if exists (select * from sysobjects where type = 'P' and name = 'sp_MSupdatesysmergearticles') drop procedure sp_MSupdatesysmergearticles if exists (select * from sysobjects where type = 'P' and name = 'sp_MSdroparticletombstones') drop procedure sp_MSdroparticletombstones if exists (select * from sysobjects wher@ type = 'P' and name = 'sp_MSproxiedmetadata') drop procedure sp_MSproxiedmetadata if exists (select * from sysobjects where type = 'P' and name = 'sp_MShelpmergearticles') drop procedure sp_MShelpmergearticles if exists (select * from sysobjects where type = 'P' and name = 'sp_MScreateretry') drop procedure sp_MScreateretry if exists (select * from sysobjects where type = 'P' and name = 'sp_MSdropretry') drop procedure sp_MSdropretry if exis@s (select * from sysobjects where type = 'P' and name = 'sp_MSenumretries') drop procedure sp_MSenumretries if exists (select * from sysobjects where type = 'P' and name = 'sp_MSdeleteretry') drop procedure sp_MSdeleteretry if exists (select * from sysobjects where type = 'P' and name = 'sp_MSgetonerow') drop procedure sp_MSgetonerow if exists (select * from sysobjects where type = 'P' and name = 'sp_MSchangearticleresolver') drop procedure@sp_MSchangearticleresolver if exists (select * from sysobjects where type = 'P' and name = 'sp_MSgetlastrecgen') drop procedure sp_MSgetlastrecgen if exists (select * from sysobjects where type = 'P' and name = 'sp_MSgetlastsentgen') drop procedure sp_MSgetlastsentgen if exists (select * from sysobjects where type = 'P' and name = 'sp_MSsetlastrecgen') drop procedure sp_MSsetlastrecgen if exists (select * from sysobjects where type = 'P' and @ame = 'sp_MSbelongs') drop procedure sp_MSbelongs if exists (select * from sysobjects where type = 'P' and name = 'sp_MSsetupbelongs') gH/6SplitNextD.  . /@pL. AL. A. L. (%A@biL .. Q7-0PE&create procedure sp_addapprole @rolename sysname, -- name of new app role @password sysname -- password for app role as -- SETUP RUNTIME OPTIONS / DECLARE VARIABLES -- set nocount on declare @ret int, -- return value of sp call @uid smallint -- CHECK FOR NULL PASSWORD if (@password is null) begin raiserror(15034,-1,-1) return (1) @ end -- CHECK PERMISSIONS -- if (not is_member('db_securityadmin') = 1) and (not is_member('db_owner') = 1) begin raiserror(15000,-1,-1) return (1) end -- DISALLOW USER TRANSACTION -- set implicit_transactions off if (@@trancount > 0) begin raiserror(15002,-1,-1,'sp_addapprole') return (1) end -- VALIDATE APPROLE NAME -- execute @ret = sp_validname @rolename if @ret <> 0 return (1) if (charindex('\', @rolename) > 0) begin rais@rror(15006,-1,-1,@rolename) return (1) end -- ERROR IF SYSUSERS NAME ALREADY EXISTS -- if user_id(@rolename) is not null begin raiserror(15363,-1,-1,@rolename) return (1) end -- OBTAIN NEW APPROLE UID (RESERVE 1-4) -- if user_name(5) IS NULL select @uid = 5 else select @uid = min(uid)+1 from sysusers where uid >= 5 and uid < (16384 - 1) -- stay in users range and user_name(uid+1) is null @ -- uid not in use if @uid is null begin raiserror(15065,-1,-1) return (1) end -- INSERT THE ROW INTO SYSUSERS -- insert into sysusers values (@uid, 32, @rolename, NULL, 0x00, getdate(), getdate(), 1, convert(varbinary(256), pwdencrypt(@password))) -- FINALIZATION: PRINT/RETURN SUCCESS -- if @@error <> 0 return (1) raiserror(15425,-1,-1) return (0) -- sp_addapprole i0e&Qreplpostcmd exte@nded procedureubi0zz&7(server internal) 0 &CREATE PROCEDURE sp_MSrepl_addrolemember @rolename sysname, @membername sysname AS -- SETUP RUNTIME OPTIONS / DECLARE VARIABLES -- set nocount on return(0) 05&-SQLTrace.dllone<. A.  x8L.).0& P.  H.4. 6. V00X t(htT\(pubid=@pubid) and (subid=@pubid) IF @db_name <> db_name() BEGIN RAISERROR (20047, 16, -1) RETURN (1) END /* ** Parameter Check: @article. ** Check to see that the @article is valid and does exist */ if @article is NULL begin raiserror (20045, 16, -1)  e n tecr* P . select @artid = artid from sysmergearticles where name = @article and pubid = @pubid if @artid is NULL begin raiserror (20046, 16, -1) return (1) end select @join_filterid=join_filterid from sysmergesubsetfilters where pubid=@pubid and artid=@artid and filtername=@filtername if @join_filterid is null begin raiserror (14028, 16, -1) return (1) end H IF @property IS NULL BEGIN CREATE TABLE #temp (properties sysname) INSERT INTO #temp VALUES ('filtername') INSERT INTO #temp VALUES ('join_filterclause') INSERT INTO #temp VALUES ('join_articlename') select * FROM #tab1 RETURN (0) END if @value is null begin raiserror (14028, 16, -1) return (1) H$##X#l|,80X t(htT\@