the publication. */ IF @article IS NULL BEGIN RAISERROR (14043, 16, -1, '@article') RETURN (1) END EXECUTE @retcode = dbo.sp_validname @article IF @retcode <> 0 or @@ERROR<>0 RETURN (1) /* ** Make sure the article exists. */ SELECT @artid = artid FROM sysmergearticles WHERE pubid = @pubid AND name = @article IF @artid IS NULL BEGIN RAISERROR (20027, 16, -1, @article) ! RETURN (1) END /* ** Parameter Check: @column. ** Check to make sure that the column exists and conforms to the rules ** for identifiers. */ IF @column IS NOT NULL BEGIN EXECUTE @retcode = dbo.sp_validname @column IF @@ERROR <> 0 OR @retcode <> 0 RETURN (1) END /* ** Parameter Check: @operation. ** The operation can be either 'add' or 'drop'. */ IF LOWER(@operation aollate SQL_Latin1_General_CP1_CS_AS) NOT IN ('add', 'drop') BEGIN RAISERROR (14019, 16, -1) RETURN (1) END /* ** column name can not be null for 'drop' operation. OK for 'add' operation */ IF LOWER(@operation collate SQL_Latin1_General_CP1_CS_AS)='drop' and @column is NULL BEGIN RAISERROR(14043, 16, -1, '@column') RETURN (1) END /* ** Can not drop non-identity, non-timestamp, mon-computed columns that are not nullable and have no default value */ SELECT @status_value=status, @objid = objid, @source_object = object_name(objid) FROM sysmergearticles WHERE artid = @artid select @colid=colid from syscolumns where id=@objid and name=@column if not exists (select * from syscolumns where id = @objid and name=@column and (isnullable=1 OR type_name(xtype)='timestamp' OR iscomputed=1)) and not exists (select * from sysconstraintq where id=@objid and colid=@colid and status & 5 = 5) and LOWER(@operation collate SQL_Latin1_General_CP1_CS_AS)='drop' and LOWER(@schema_replication collate SQL_Latin1_General_CP1_CS_AS)='false' and ColumnProperty(@objid, @column, 'IsIdentity') <> 1 BEGIN RAISERROR(21165, 16, -1, @column) return (1) END if LOWER(@operation collate SQL_Latin1_General_CP1_CS_AS) = 'drop' begin select @indid = indid from sysindexes where id = @objid and (status & 2048) <> 0 /* PK index */ select @index_cnt = 1 while (@index_cnt <= 16) begin select @pkkey = INDEX_COL(@source_object, @indid, @index_cnt) if @pkkey is NULL break if @pkkey=@column begin raiserror(21250, 16, -1, @column) return (1) end select @index_cnt = @index_cnt + 1 end /* ** Check for unique index defined on this column - to disallow such a column from being dropped */ if exists (select * from sysindexes where id=@objid and (status & @v_unique_index = @v_unique_index or status & @v_unique_constraint = @v_unique_constraint)) begin declare @keys varbinary(816) declare @i int declare !check_unique CURSOR L 0D`OCAL FAST_FORWARD for select indid from sysindexes where id=@objid and (status & @v_unique_index = @v_unique_index or status & @v_unique_constraint = @v_unique_constraint) open #check_unique fetch #check_unique into @indid while (@@fetch_status<>-1) begin SELECT @i = 1 WHILE (@i <= 16) BEGIN ! SELECT @pkkey = INDEX_COL(@source_object, @indid, @i) if @pkkey is NULL break if @pkkey=@column BEGIN if LOWER(@schema_replication collate SQL_Latin1_General_CP1_CS_AS)='true' raiserror(21265, 16, -1, @column, @source_object) else raiserror(21347, 16, -1, @column) ! close #check_unique deallocate #check_unique return (1) END select @i = @i + 1 END fetch #check_unique into @indid end close #check_unique deallocate #check_unique end /* ** Check for foreign key constraints */ if exists (select * frmm sysconstraints where status & @v_foreign_key=@v_foreign_key and id=@objid) begin if @column in (select name from syscolumns where id=@objid and colid in (select colid from sysconstraints where status & @v_foreign_key=@v_foreign_key and id=@objid)) begin raiserror(21513, 16, -1, @column) return (1) end end end begin tran save TRANSACTION articlecolumn /* ** Make sure thau the column is not NULL - if NULL set to 0x00. */ SELECT @columns = columns FROM sysmergearticles WHERE artid = @artid and pubid=@pubid IF @columns IS NULL UPDATE sysmergearticles SET columns = 0x00 WHERE artid = @artid and pubid=@pubid /* ** If no columns are specified, or if NULL is specified, set all ** the bits in the 'columns' column so all columns will be included, */ IF @column IS NULL BEGIN SELECT @cnt = max(colid), @idy = 1 FROM syscolumns WHERE id = @objid SELECT @columns = NULL WHILE @idx <= @cnt BEGIN /* to make sure column holes will not be included */ if exists (select * from syscolumns where colid=@idx and id=@objid and (@sync_mode=0 OR (iscomputed<>1 and type_name(xtype) <>'timestamp'))) begin exec sp_MSsetbit @bm=@columns OUTPUT, @coltoadd=@idx, @toset = 1 if @@ERROR<>0 or @retcode<>0 goto FAILURE update syscolumns set colstat=colstat | @mergepublish where id=@objid and colid=@idx if @@ERROR<>0 goto FAILURE end SELECT @idx = @idx + 1 END UPDATE sysmergearticles SET columns = @columns WHERE name = @article AND pubid = @pubid if @sync_mode=1 and exists (select * from syscolumns where id=@objid and (iscomputed=1 or type_name(xtype)='timestamq')) UPDATE sysmergearticles SET vertical_partition = 1 WHERE name = @article AND pubid = @pubid END ELSE BEGIN /* if @column is NULL, meanning all columns are in, do not bump up version to Shiloh. */ if LOWER(@schema_replication collate SQL_Latin1_General_CP1_CS_AS)='false' raiserror(21351, 10, -1, @publication) else raiserror(21352, 10, -1, @publication) exec @retcode e_&DesF-`s~9O1<1S` create procedure sp_MScheckmetadatamatch (@metatype tinyint, @rowguid uniqueidentifier, @tablenick int, @lineage varbinary(255), @match int output) as if (@metatype = 3) begin if not exists (select * from dbo.MSmerge_contents where tablenick = @tablenick and rowguid = @rowguid) select @match = 1 else select @match = count(*) from dbo.MSmerge_contents (updlock) where tablenick = @tablenick and rowguid = @rowguid and lineage = @lineage end else select @match = count(*) from dbo.MSmerge_contents (updlock) where tablenick = @tablenick and rowguid = @rowguid and lineage = @lineage return (0) 8  Fom` FveH$$~C F$$& FH Fba88 lep FmaFH$0P C FLJ$'$ F'onc Fx CntL$nc( FntU(L$X~Cx F F FY/ 0@0 F Fco ` ~C(@ F@ إ F F(sysmergepublicationsФ F F` F]02ubr ` ~C( Fc_modeidsol@allow_push_idt@allow_pull_idl@allow_anonymous_id@centralized_conP Ftsd@pubidebl$$ ~C F_hhyn F_f rs@s88 ( Flt Fer488 ANث FЩ FZ200sn( Fcr ` ~C(0 F_portan@ftp_subdirectoryho@ftp_login @enc_ftp_passwordop@conflict_retention Fp_s_@a88 F:Nn_ F F_i4p F messagetbs88 Fd_na88 ت Fco@publicationmax~Ccu4t_ F Fmi4^H F F4 F0 F[00  F ` ~C( F@ Fch P FH FI F C88 FX FU(88 ~C F F@ F\00_pns ` ~C(x F@sF88 T 00 F_cp F8WDEndhhnsȮ Fp' ic t F F F Fb99  F ` ~C( F C(H FJ(@ FH F F ` F C F F@ F^2z7 F+F F ` ~C(x F@  F ` C( Fh F F(@ F Fa99 ` ~C( F ( Fsubidpartneridг FCp F4 Fns FneurLOWERe@propertySQL_Latin1_General_CP1_CS_ASouryp3SQL_Latin1_General_CP1_CS_AS( Fsr8$e8~C F $88 Feiش F Fus88  FF38M0 Fstty0 F FF3 5descriptionе F $ F descriptionFC F'A hh FBstatusbyp$ Fstatus Fh'C hh FcrBbs F@ Fti ypretention4 $0 F retention F F@'Ccr hh @ F_tB4@ Fض F sync_modesy $ F sync_modee8 F'A88 hh FBgi F Fme bsallow_pushe F $ F allow_push F&C hh ib FerBat FH F F 4allow_pull $X F allow_pullon F&Cri hh 4h FBh F Fȹ F stallow_anonymoused$ Fallow_anonymous0 F&C hh st( FidB( F F enabled_for_internet$ Fenabled_for_internet Fx&Csy hh ip FsB Fx F centralized_conflictsub@p$ Fcentralized_conflicts FP&C@s hh meػ F@sBitػ FP F@p snapshot_readyom$ Fsnapshot_readye( F(&Cd hh FB F( F F snapshot_in_defaultfolder$` Fsnapshot_in_defaultfolder F&C hh ub FtiBer F Fam tdalt_snapshot_folderx"F$8 Falt_snapshot_folderx F%C@ hh P FBP Fн F@ pre_snapshot_script$ Fpre_snapshot_script F%C F hh FB F FR post_snapshot_scriptV$ Fpost_snapshot_script0 F}, A70D` = sp_MSBumpupCompLevel @pubid, 40 if @@ERROR<>0 or @retcode<>0 GOTO FAILURE SELECT @columnid = colid, @iscomputed=iscomputed, @xtype=xtype FROM syscolumns WHERE id = @objid AND name = @column IF ((@@error <> 0) OR (@columnid IS NULL)) BEGIN RAISERROR (21166, 16, -1, @column) GOTO FAILURE END /* ** for character mode publications, we do not allow adding computed column or timestamp columns ** into the vertical parititioning. */ if @sync_mode=1 and (@iscomputed = 1 or type_name(@xtype) ='timestamp') and LOWER(@operation collate SQL_Latin1_General_CP1_CS_AS) = 'add' begin if LOWER(@schema_replication collate SQL_Latin1_General_CP1_CS_AS)='false' begin raiserror(21269, 16, -1) ! GOTO FAILURE end else begin if @@TRANCOUNT >0 begin ROLLBACK TRANSACTION articlecolumn COMMIT TRAN end return (0) end end if ColumnProperty(@objid, @column, 'isrowguidcol') = 1 and LOWER(@operation collate SQL_Latin1_General_CP1_CS_AS) = 'drop' begin RAISERROR(21162, 16, -1) ! GOTO FAILURE end exec @in_partition = sp_MStestbit @bm=@columns, @coltotest=@columnid if @in_partition=1 and LOWER(@operation collate SQL_Latin1_General_CP1_CS_AS) = 'add' and LOWER(@schema_replication collate SQL_Latin1_General_CP1_CS_AS)='false' begin RAISERROR(21335, 10, -1, @column) GOTO FAILURE end if @in_partition=0 and LOWER(@operation collate SQL_Latin1_General_CP1_CS_AS) = 'drop' and LOWER(@schema_repmication collate SQL_Latin1_General_CP1_CS_AS)='false' begin RAISERROR(21336, 10, -1, @column) GOTO FAILURE end SELECT @columns = columns, @filter_clause=subset_filterclause, @ins_conflict_proc=ins_conflict_proc, @conflict_table=conflict_table FROM sysmergearticles WHERE name = @article AND pubid = @pubid IF LOWER(@operation collate SQL_Latin1_General_CP1_CS_AS) = 'add' begin exec @retcode = sp_MSsetbit @bm = @columns OUTPUT, @coltoadd=@columnid, @toset=1 if @@ERROR<>0 or @retcode<>0 GOTO FAILURE update syscolumns set colstat=colstat | @mergepublish where id=@objid and colid=@colid if @@ERROR<>0 goto FAILURE end ELSE begin exec @retcode = sp_MSsetbit @bm = @columns OUTPUT, @coltoadd=@columnid, @toset=0 if @@ERROR<>0 or @retcode<>0 ! GOTO FAILURE if @columns = 0x00 begin raiserror(21345, 16, -1) goto FAILURE end exec @retcode = sp_MSclearcolumnbit @pubid, @artid, @column if @@ERROR<>0 or @retcode<>0 goto FAILURE end /* ** Set vertical_partitioning flag so that publication view would be re-generated even ** if there is nou subsetfilters nor join filters */ UPDATE sysmergearticles SET columns = @columns, vertical_partition=1 WHERE name = @article AND pubid = @pubid IF @@ERROR <> 0 BEGIN RAISERROR (14021, 16, -1) GOTO FAILURE END select @column_list_1_to_15 = NULL, @column_list_16_to_30 = NULL, @column_list_31_to_45 = NULL, @column_list_46_to_60 = NULL, @column_list_61_to_75 = NULL, @column_list_76_to_90 = NULL, @column_list_91_to_105 = N0D`ULL, @column_list_106_to_120 = NULL, @column_list_121_to_135 = NULL, @column_list_136_to_150 = NULL, @column_list_151_to_165 = NULL, @column_list_166_to_180 = NULL, @column_list_181_to_195 = NULL, @column_list_196_to_210 = NULL, @column_list_211_to_225 = NULL, @column_list_226_to_240 = NULL, @column_list_241_to_255 = NULL, @column_list_256_to_270 = NULL /* ** check to see if that column can be dropped based on current aruicle's filter clause ** and if the article is involved in any join_filter_clauses - to make sure the drop of ** one column does not cripple any such joins */ if ((@filter_clause is not NULL and @filter_clause <>'' ) or exists (select * from sysmergesubsetfilters where pubid=@pubid and (artid=@artid or join_articlename=@article))) and LOWER(@operation collate SQL_Latin1_General_CP1_CS_AS) = 'drop' begin exec @retcode = sp_MSgetcolumnlist @pubid = @pubid, @column_list_1_to]15 = @column_list_1_to_15 output, @column_list_16_to_30 = @column_list_16_to_30 output, @column_list_31_to_45 = @column_list_31_to_45 output, @column_list_46_to_60 = @column_list_46_to_60 output, @column_list_61_to_75 = @column_list_61_to_75 output, @column_list_76_to_90 = @column_list_76_to_90 output, @column_list_91_to_105 = @column_list_91_to_105 output, @column_list_106_to_120 = @column_list_106_to_120 output, @column_list_121_to_135 = @column_list_121_to]135 output, @column_list_136_to_150 = @column_list_136_to_150 output, @column_list_151_to_165 = @column_list_151_to_165 output, @column_list_166_to_180 = @column_list_166_to_180 output, @column_list_181_to_195 = @column_list_181_to_195 output, @column_list_196_to_210 = @column_list_196_to_210 output, @column_list_211_to_225 = @column_list_211_to_225 output, @column_list_226_to_240 = @column_list_226_to_240 output, @column_list_241_to_255 = @column_list_241_to]255 output, @column_list_256_to_270 = @column_list_256_to_270 output, @source_objid = @objid if @@ERROR<>0 or @retcode<>0 GOTO FAILURE select @object_view='TEMP_VIEW_' + @source_object --@source_object is not quoted select @qual_object_view=quotename(@object_view) exec @retcode = sp_MSget_qualified_name @objid, @qual_source_object OUTPUT if @@ERROR<>0 or @retcode<>0 goto FAILURE select @quoted_source_object=QUMTENAME(@source_object) exec ('create view ' + @qual_object_view + ' as select ' + @column_list_1_to_15 + @column_list_16_to_30 + @column_list_31_to_45 + @column_list_46_to_60 + @column_list_61_to_75 + @column_list_76_to_90 + @column_list_91_to_105 + @column_list_106_to_120 + @column_list_121_to_135 + @column_list_136_to_150 + @column_list_151_to_165 + @column_list_166_to_180 + @column_list_181_to_195 + @column_list_196_to_210 + @column_list_211_to_225 + @column_list_226_to_240 + @column_list_241_to_255 + @column_list_256_to_270 + ' from ' + @qual_source_object + ' ' + @quoted_source_object) if @@ERROR<>0 GOTO FAILURE if @filter_clause is not NULL and @filter_clause <>'' begin exec ('declare @test int select @test=1 from ' + @qual_object_view + ' ' + @quoted]source_object + ' where ' + @filter_clause) if @@ERROR<>0 begin exec('drop view ' + @qual_object_view) raiserror(21256, 16, -1, @filter_clause, @source_object) GOTO FAILURE end end end /* ** Check to make sure dropping a column will not breaking any other articles _atin1_General_CP1_CS_`sL920D`that using current article as join_article */ if exists (select * from sysmergesubsetfilters where pubid=@pubid and (artid=@artid or join_articlename=@article)) and LOWER(@operation collate SQL_Latin1_General_CP1_CS_AS) = 'drop' begin declare @join_articlename sysname declare @tmp_artid uniqueidentifier declare @join_objid int declare @join_object sysname declare @qual_join_object nvarchar(300) declare @quoted_join_object nvarchar(150) declare per_article CURSOR LOCAL FAST_FORWARD FOR select artid, join_filterclause, join_articlename from sysmergesubsetfilters where pubid=@pubid and (join_articlename=@article or artid=@artid) for READ ONLY open per_article fetch per_articlf into @tmp_artid, @filter_clause, @join_articlename while (@@fetch_status<>-1) begin if @artid<>@tmp_artid select @join_objid=objid from sysmergearticles where pubid=@pubid and artid=@tmp_artid else select @join_objid=objid from sysmergearticles where pubid=@pubid and name=@join_articlename select @join_object = object_name(@join_objid) select @qual_join_object = quotenane(user_name(uid)) + '.' + quotename(name) from dbo.sysobjects where id = @join_objid select @quoted_join_object = quotename(object_name(@join_objid)) if @join_object is not NULl and @join_object<>'' begin exec ('declare @test int select @test=1 from ' + @qual_object_view + ' ' + @quoted_source_object + ', ' + @qual_join_object + ' ' + @quoted_join_object + ' where ' + @filter_clause) if @@ERROR<>0 begin close per_article deallocate per_article raiserror(21256, 16, -1, @filter_clause, @source_object) GOTO FAILURE end end fetch per_article into @tmp_artid, @filter_clause, @join_articlename end close per_article deallocate per_article end END " /* ** if snapshot is ready, change it to obsolete to force another snapshot run. ** Note this is the third value of snapshot_ready. 0 for not ready, 1 for OK, 2 for obsolete */ IF EXISTS (SELECT * FROM sysmergepublications WHERE pubid=@pubid and snapshot_ready>0) and LOWER(@schema_replication collate SQL_Latin1_General_CP1_CS_AS)='false' BEGIN update sysmergearticles set status=1, conflict_table=NULL where pubid=@pubid and artid=@artid and stbtus<>5 and status <>6 if @@ERROR<>0 goto FAILURE /* ** Force a re-generation of conflict table and its ins_proc */ if object_id(@ins_conflict_proc) is not NULL begin set @quoted_source_object= quotename(@ins_conflict_proc) exec ('drop proc ' + @quoted_source_object) if @@ERROR<>0 goto FAILURE end if objecv_id(@conflict_table) is not NULL begin set @quoted_source_object= quotename(@conflict_table) exec ('drop table ' + @quoted_source_object) if @@ERROR<>0 goto FAILURE end /* ** make sure we know we really want to do this. */ if @force_invalidate_snapshot = 0 begin raiserror(20607, 16, -1) " goto FAILUREi0D`4 end update sysmergepublications set snapshot_ready=2 where pubid=@pubid if @@ERROR<>0 goto FAILURE if @force_reinit_subscription = 0 and @status_value<>5 --5 is the value for new_inactive begin raiserror(20608, 16, -1) goto FAILURE end --do a global re if @force_reinit_subscription = 1 begin --global reinitialization will bump up backward-comp-level to SP2. exec @retcode = sp_MSreinitmergepublication @publication if @retcode<>0 or @@ERROR<>0 goto FAILURE end /* ** Even for vertical partitioning on new article - we do not need to bumpup backward-comp-level ** else begin --bump up the backward-comr-level so that only 80 subscribers can use it. exec @retcode = sp_MSBumpupCompLevel @pubid, 40 if @@ERROR<>0 or @retcode<>0 GOTO FAILURE end */ END COMMIT TRANSACTION if exists (select * from sysobjects where id = object_id(@qual_object_view) and ObjectProperty (id, 'IsView') = 1) begin exec ('drop view ' + @qual_object_view) end return (0) FAILURE: if @@TRANBOUNT >0 begin ROLLBACK TRANSACTION articlecolumn COMMIT TRAN end if exists (select * from sysobjects where id = object_id(@qual_object_view) and ObjectProperty (id, 'IsView') = 1) begin exec ('drop view ' + @qual_object_view) end return (1) >o_ir ` ~C( F 3SQL_Latin1_General_CP1_CS_AS Fti8$O,D8 F$ $tx F F@sync_modeid8 00 FDC F Fhh F F F388 h F@ F488 p}C F8 Fd6:<(}CȂ}C ` ~C(p F@ *S(` F ` F C( F $ Fti40 F Fg<<yp F ` ~C( Fctive_directoryad_guidnamesysnamedatabase_default F F F$ad_g FamLOWER@propertySQL_Latin1_General_CP1_CS_ASr_ae_3SQL_Latin1_General_CP1_CS_AS F@8$8~C F$@88 F F F88 FF38M( F( FF3 5pre_snapshot_script$ Fpre_snapshot_scriptx FH(ChhLOWER@propertySQL_Latin1_General_CP1_CS_AS3SQL_Latin1_General_CP1_CS_AS0 F`z t 0ha CREATE PROCEDURE sp_helpmergearticlecolumn ( @publication sysname, /* The publication name */ @article sysname /* The article name */ ) AS SET NOCOUNT ON /* ** Declarations. */ declare @colid int declare @colmax int declare @colname sysname declare @published bit declare @columns binary(128) declare @pubid uniqueidentifier declare @retcode int declare @objid int declare @publisher sysname declare @publisher_db sysname select @publisher = @@SERVERNAME select @publisher_db = db_name() /* ** 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 EXECUTE @retcode = dbo.sp_validname @publicatiom IF @retcode <> 0 or @@ERROR<>0 RETURN (1) SELECT @pubid = pubid FROM sysmergepublications WHERE name = @publication and LOWER(publisher)=LOWER(@publisher) and publisher_db = @publisher_db IF @pubid IS NULL BEGIN RAISERROR (20026, 11, -1, @publication) RETURN (1) END -- Security check. (Done after @pubid retrieval, because this param is needed here.) if 1 <> {fn ISPALUSER(@pubid)} and (1 <> is_member('repmmonitor') or is_member('replmonitor') is null) begin raiserror(15247,-1,-1) return 1 end /* ** Parameter Check: @article. ** The @article name must conform to the rules for identifiers. */ IF @article IS NULL BEGIN RAISERROR (14043, 16, -1, '@article') RETURN (1) END EXECUTE @retcode = dbo.sp_validname @article IF @retcode <> 0 or @@ERROR<>0 RETURN (1) /* ** Parameter Check: @article, @publicatimn. ** Check to make sure that the article exists in this publication. */ IF NOT EXISTS (SELECT * FROM sysmergearticles WHERE pubid = @pubid AND name = @article) BEGIN RAISERROR (20027, 11, -1, @article) RETURN (1) END SELECT @columns = columns, @objid=objid FROM sysmergearticles WHERE name = @article AND pubid = @pubid create table #tmp (column_id int, column_name sysname collate database_default, published bit) select TOP 1 @colie = colid from syscolumns where id = @objid order by colid ASC select TOP 1 @colmax = colid from syscolumns where id = @objid order by colid DESC while (@colid <= @colmax) begin if exists (select * from syscolumns where id = @objid and colid = @colid) begin select @colname = name from syscolumns where id=@objid and colid=@colid exec @retcode = sp_MStestbit @bm=@columns, @coltotest=@colid if @retcode<>0 select @published=1 else select @published=0 insert into #tmp values(@colid, @colname, @published) end select @colid=@colid + 1 end select * from #tmp drop table #tmp idC(488 *C,Cid @objidC,CHxEhh colide3(444 ,C -Ccolid"-C2C/C`&C()C()C/C2CCDE  PC(.C 3C-CC00\DE.Ce \DE @.D .D8PCE88 H.Dbi colid(444  /C colid~C8/C00444 /CCcolidsysconstraintsY`V b  2C0C xEj@xE0CxEsysconstraintsE^Hstatus88(488 8/C x1Cstatus @v_foreign_key01C}C88 p3C@v_foreign_key1C}C88hh id C(488 01Ch2Cid@objid 2CHxEhh 1C`xE88 2C 003C3C4C  PC(4C)C3C8DS(0088 4C SEe 34ChSE88C00hSEC00SE) PSE4C 8-C-C88hh3C2Chh-CxE 4C 8800p5C 6C 7CF  PC(6C`&CP6C(6CS(00`>FC88 x6Css>FCe$(?FC e$ ?FC6Ce$ca CCe$87C  PC)Chh x5CH5C8Chh`7CC E88 7C7C488 h;Cp9CLM9CpC ` PC(8C88 H89CC Ce(3HC CE88 HumXC`8C88 9C T ;C9C4:C message88 H:Ce$88 x:C@column PCfF4e:CP:C34:C :C4C>CMM  ` PC(>C0P,DE88 HX,D W,De3 ],D>C C 4=CPaC`CMN `aC PC( `Ce3um`C?C C C88 H`*5s0ȃccreate function system_function_schema.fn_dblog ( @start nvarchar (22) = NULL, @end nvarchar (22) = NULL ) returns table as return select * from OpenRowset (DBLog, @start, @end) n0c create function system_function_schema.fn_updateparameterwithargument( @command nvarchar(3200), @parameter nvarchar(200), @argument nvarchar(1000) ) returns nvarchar(3200) begin declare @pattern nvarchar(806) declare @resulting_command nvarchar(3200) declare @command_length int declare @pattern_start int declare @first_iteration bit declare @parameter_length int declare @found_parameter bit select @first_iteration = 1 select @found_parameter = 0 select @pattern = fn_generateparameterpattern(@parameter) select @parameter_length = len(@parameter) + 1 -- leading - or / select @resulting_command = N'' select @pattern_start = patindex(@pattern,@command) if @argument is null begin select @argument = N'' end while @pattern_start <> 0 and @pattern_start is not null begin select @command_length = len(@command) -- Check if the pattern found is properly delimited in the command, -- If so, try to change the argument of the parameter with the given -- value. if (@pattern_start = 1 and @first_iteration = 1 or (@pattern_start > 1 and fn_chariswhitespace(substring(@command, @pattern_start - 1, 1)) = 1)) and (fn_chariswhitespace(substring(@command, @pattern_start + @parameter_length, 1)) = 1) begin -- Add everything before the parameter to the resulting command select @resulting_command = @resulting_command + rtrim(substring(@command, 1, @pattern_start - 1)) -- Add back the parameter with the specified argument if @resulting^command <> '' begin select @resulting_command = @resulting_command + N' ' end select @resulting_command = @resulting_command + N'-' + @parameter + N' ' + rtrim(ltrim(@argument)) + ' ' -- Remove the leading part of the command up to the begining of the -- matching pattern select @command = substring(@command, @pattern_start, @command_length - @pattern_start + 1) -- Remove all traces of the specififd parameter from the remaining -- command line select @command = fn_removeparameterwithargument(@command, @parameter) select @found_parameter = 1 end else begin -- Not a properly delimited parameter so transfer the -- matching substring to the resulting command and -- eat the substring in the process select @resulting_command = @resulting_command + substring(@command, 1, @pattern_start + @rarameter_length - 1) select @command = substring(@command, @pattern_start + @parameter_length, @command_length - @pattern_start - @parameter_length + 1) end select @first_iteration = 0 select @pattern_start = patindex(@pattern, @command) end select @resulting_command = @resulting_command + @command if @found_parameter = 0 begin select @resulting_command = rtrim(@resulting_command) + N' ' + N'-' + @parameter + N' ' + rtrim(ltrim(@argument)) end return @resulting_command end 0Cc create procedure sp_MSreinit_hub @publisher sysname, @publisher_db sysname, @publication sysname, @upload_first bit AS declare @retcode int declare @pubid uniqueidentifier declare @hub_pubname sysname declare @hub_publisher sysname declare @hub_publisher_db sysname declare @hub_pubid uniqueidentifier declare @schematext nvarchar(4000) declare @schemaversinn int declare @schemaguid uniqueidentifier declare @schematype int /* ** Security Check. ** We use login_name stored in syssubscriptions to manage security */ exec @retcode= dbo.sp_MSreplcheck_subscribe if @@ERROR <> 0 or @retcode <> 0 return(1) select @pubid=pubid from sysmergepublications where name=@publication and UPPER(publisher)=UPPER(@publisher) and publisher_db=@publisher_db BEGIN TRAN SAVE TRAN reinithub /* Find all publicationr that are being republished at the subscriber */ declare reinit_hub CURSOR LOCAL FAST_FORWARD FOR select DISTINCT p.pubid, p.name, p.publisher, p.publisher_db FROM sysmergepublications p where UPPER(p.publisher)=UPPER(@@SERVERNAME) and p.publisher_db=db_name() and exists (select * from sysmergearticles where (objid in (select objid from sysmergearticles where pubid=@pubid)) and (objid in (select objid from sysmergearticles where pubid=p.pubid))) and p.pubid<>@rubid FOR READ ONLY open reinit_hub fetch reinit_hub into @hub_pubid, @hub_pubname, @hub_publisher, @hub_publisher_db while (@@fetch_status<>-1) begin if @upload_first=1 begin update sysmergesubscriptions set status=5 where pubid=@hub_pubid if @@ERROR<>0 goto FAILURE end select @schematext = 'exec sp_MSreinit_hub '+ QUOTENAME(@hub_publisher) + ', ' + QUOTENAME(@hub_publisher_db) + ', ' + QUOTENAME(@hub_pubname) + ', ' + convert(nvarchar, @upload_first) select @schemaverrion = schemaversion from sysmergeschemachange if (@schemaversion is NULL) set @schemaversion = 1 else select @schemaversion = 1 + max(schemaversion) from sysmergeschemachange set @schemaguid = newid() if @upload_first=0 set @schematype = 12 /* reinit_all */ else set @schematype = 14 /*reinitwithupload */ exec @retcode=sp_MSinsertschemachange @hub_pubid, @schemaguid, @schemaversion, @schemaguid, @schematype, @schematext if @@ERROR<>0 or @retcode<>0 begin sflect @retcode = 1 GOTO FAILURE end raiserror(21354, 10, -1, @hub_pubname) exec @retcode=sp_MSBumpupCompLevel @hub_pubid, 40 if @@ERROR<>0 or @retcode<>0 GOTO FAILURE update sysmergepublications set snapshot_ready=2 where pubid=@hub_pubid if @@ERROR<>0 goto FAILURE fetch next from reinit_hub into @hub_pubid, @hub_pubname, @hub_publisher, @hub_publisher_db end close reinit_hub deallocate reinit_hub COMMIT TRAN return (0) FAILURE: close reinit_hub deallocatf reinit_hub raiserror('Error occurred when applying reinit-all command at subscribers', 16, -1) if @@TRANCOUNT >0 begin ROLLBACK TRANSACTION reinithub COMMIT TRAN end return (0) ACsyscolumns^Hcolstatcolstat(444 ; Farcolstat@mergepublish ACPCch88  AC444 @X< Ftcolstatid@s(488 p; F< Fid; F@objidp< FHxELhh colid(444 p< F P= Fcolid@idx!ACPChh < F AC p= Fna YC ? FH? F"pWW@YChYC= F ` PC(> F@   $> F uniqueidentifierx> Fid4$$H? F ? F @artidH? F> F8? F4! FYCWW:( ` PC( YCH<`]C0dcreate procedure sp_MSscript_update_pubwins ( @publication sysname -- publication name ,@article sysname -- article name ,@objid int -- object id ,@columns binary(32) -- columns replicated ) as begin declare @cmd nvarchar(4000) ,@artid int ,@pubid int ,@qualname nvarchar(512) ,@dest_table sysname ,@dest_owner nvarchar(260) ,@rc int ,@fhasnonpkuniquekeys int -- -- initialize the vars we will use -- select @pubid = pubid from syspublications where name = @publication select @artid = artid, @dest_table = dest_table, @dest_owner = dest_owner from sysarticles where name = @article and pubid = @pubid select @dest_owner = case when (@dest_owner IS NULL) then N'' else quotename(@dest_owner) + N'.' end exec sp_MSget_qualified_name @objid, @qualname OUTPUT -- -- check if this article has non PK unique keys -- exea @fhasnonpkuniquekeys = dbo.sp_repltablehasnonpkuniquekey @tabid = @objid -- -- start scripting -- select @cmd = N' ' + N'-- ' + N'-- -------------------------------------------------------------------- ' + N'-- Now the generation phase ' + N'-- Use the conflict case value to decide what to do ' + N'-- -------------------------------------------------------------------- ' + N'-- ' insert into #proctext(procedure_text) values( @cmd ) select @cmd = N' if (@execution_mode = @QPubWins) begin ' + N'-- ' + N'-- Publisher wins resolution ' + N'-- ' insert into #proctext(procedure_text) values( @cmd ) -- -- declare fetch variables for cursor -- exec @rc = sp_scriptpubwinsrefreshcursorvars @objid -- -- continue scripting -- select @cmd = N' ' + N'-- ' + N'-- -------------------------------------------------------------------- ' + N'-- Perform single row delete generations first ' + N'-- -------------------------------------------------------------------- ' + N'-- ' insert into #proctext(procedure_text) values( @cmd ) select @cmd = N' ' + N'-- ' + N'-- Generate DELETE for PK = OLD_PK ' + N'-- if (@cftcase in (11,12,13,16,18,21,22,23,24)) begin' insert into #proctext(procedure_text) values( @cmd ) -- -- generate delete compensating cmd with OLD_PK -- select @cmd = N' select @cmd = ''DELETE ' + master.dbo.fn_MSgensqescstr(@dest_owner) collate database_default + quotename(master.dbo.fn_MQgensqescstr(@dest_table) collate database_default) + N' '' + ' insert into #proctext(procedure_text) values( @cmd ) exec dbo.sp_MSscript_where_clause @objid, @columns, 'qcft_comp', NULL, 0, 'del' -- -- script the sending command -- exec sp_MSscript_compensating_send @pubid, @artid, 0, 1 -- -- continue scripting -- select @cmd = N' end ' + N'-- ' + N'-- Generate DELETE for PK = NEW_PK ' + N'-- if (@cftcase in (1,12,14)) begin' insert into #proctext(procedure_text)!values( @cmd ) -- -- generate delete compensating cmd with NEW_PK -- select @cmd = N' select @cmd = ''DELETE ' + master.dbo.fn_MSgensqescstr(@dest_owner) collate database_default + quotename(master.dbo.fn_MSgensqescstr(@dest_table) collate database_default) + N' '' + ' insert into #proctext(procedure_text) values( @cmd ) exec dbo.sp_MSscript_where_clause @objid, @columns, 'qcft_comp', NULL, 0, 'ins' -- -- script the sending command -- exec sp_MSscript_compensating_send @pubid,!@artid, 0, 1 -- -- continue scripting -- select @cmd = N' end' insert into #proctext(procedure_text) values( @cmd ) -- -- this scripting is specific to non PK unique keys -- if (@fhasnonpkuniquekeys = 1) begin -- -- continue scripting -- select @cmd = N' '+N'-- '+N'-- Generate delete for OLD values of non PK keys '+N'-- if (@cftcase in (17,18,23,24)) begin' insert into #proctext(procedure_text) values( @cmd ) -- -- generate delete compensating command for OLD values o1to_165output EeC4 .E `@column_list_151_to_165@column_list_166_to_180@column_list_166_to_180outputEgCis4 .hE@column_list_166_to_180@column_list_181_to_195@column_list_181_to_195outputSExhC4.PE_G@column_list_181_to_195@column_list_196_to_210@column_list_196_to_210outputEiC4.8E@column_list_196_to_210@column_list_211_to_225@column_list_211_to_225outputDEEhkChh4. E@column_list_211_to_2254@column_list_226_to_240@column_list_226_to_240outputElC4.E@E@column_list_226_to_240@column_list_241_to_255@column_list_241_to_255output