Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSreinitmergepublication

  No additional text.


Syntax
create procedure sys.sp_MSreinitmergepublication
    @publication    sysname,
    @upload_first    bit = 0
AS
    declare @pubid                uniqueidentifier
    declare @schematext            nvarchar(4000)
    declare @schemaversion        int
    declare @schemaguid            uniqueidentifier
    declare @schematype            int
    declare @publisher            sysname
    declare @retcode            int
    declare @publisher_db        sysname
    declare @compatlevel int
    declare @snapshot_ready int
    declare @SCHEMA_TYPE_DROPARTICLE int

    set nocount on

    select @SCHEMA_TYPE_DROPARTICLE = 28

    select @publisher=publishingservername()
    select @publisher_db = db_name()

    select @pubid=pubid, @compatlevel = backward_comp_level, @snapshot_ready=snapshot_ready from dbo.sysmergepublications
        where name=@publication and UPPER(publisher)=UPPER(publishingservername()) and publisher_db=db_name()

    if @compatlevel < 30
    begin
        raiserror(21353,10, -1,@publication)
        exec @retcode=sys.sp_MSBumpupCompLevel @pubid, 30 --for 7.0 SP2, which has limited support for this
        if @@ERROR<>0 or @retcode<>0
            return (1)
    end

    update dbo.sysmergesubscriptions set schemaversion=0, recgen = NULL, recguid=NULL, sentgen=NULL, sentguid = NULL
        where subid<>pubid and pubid=@pubid and subscription_type=0
    if @@ERROR<>0
        return (1)

    update dbo.sysmergesubscriptions set schemaversion=-1, recgen = NULL, recguid=NULL, sentgen=NULL, sentguid = NULL
        where subid<>pubid and pubid=@pubid and subscription_type>0
    if @@ERROR<>0
        return (1)

    -- set all article status to inactive as a starting point - which sort or cleanup the newly added status
    -- 5 and 6.
    if @upload_first=0 --do not set status to active if upload_first=true, otherwise trigger creation will fail.
    begin
        if exists (select * from dbo.sysmergearticles where pubid = @pubid and (status=5 or status=6))
        begin
            update dbo.sysmergearticles set status=1 where pubid=@pubid
            -- delete from sysmergeschemachange so that the incrementally added article schema changes all get cleanedup
            -- don't delete dropmergearticle schema changes.
            delete from dbo.sysmergeschemachange where pubid=@pubid and schematype not in (@SCHEMA_TYPE_DROPARTICLE)
            -- update the snapshot status so that rerun of snapshot can be forced
            if @snapshot_ready > 0
                update dbo.sysmergepublications set snapshot_ready=2 where pubid=@pubid
            if @@ERROR<>0
                return (1)
        end
    end

    select @schematext = 'exec dbo.sp_MSreinit_hub '+ QUOTENAME(@publisher) + ', ' + QUOTENAME(@publisher_db) + ', ' + QUOTENAME(@publication) + ', ' + convert(nvarchar, @upload_first)
    select @schemaversion = schemaversion from dbo.sysmergeschemachange
    if (@schemaversion is NULL)
        set @schemaversion = 1
    else
        select @schemaversion = 1 + max(schemaversion) from dbo.sysmergeschemachange
    set @schemaguid = newid()
    if @upload_first = 0
        set @schematype = 12 /* reinit_all */
    else
        set @schematype = 14 /* reinit_with_upload*/
    exec @retcode=sys.sp_MSinsertschemachange @pubid, null, @schemaversion, @schemaguid, @schematype, @schematext
    if @@ERROR<>0 or @retcode<>0
        return (1)

    -- make sure we don't falsely use transitive recgen optimization
    update dbo.sysmergesubscriptions
        set replicastate= newid() where pubid = @pubid

 
Last revision 2008RTM
See also

  sp_addmergearticle (Procedure)
sp_addmergefilter (Procedure)
sp_changemergearticle (Procedure)
sp_changemergefilter (Procedure)
sp_changemergepublication (Procedure)
sp_changemergesubscription (Procedure)
sp_dropmergearticle (Procedure)
sp_dropmergefilter (Procedure)
sp_mergearticlecolumn (Procedure)
sp_MSdrop_rladmin (Procedure)
sp_MSreinitoverlappingmergepublications (Procedure)
sp_reinitmergesubscription (Procedure)
       



News

  Query a named instance
Sybase+ASE+silent+install
SQL 2008 R2
Deprecated procedures in SQL2008
Reporting Services item-level role definitions
Create all your missing indexes
Converting datetime field
Start MSSQL Server Profiler at time
Replicating MSSQL Server views
Exploring Microsoft Sharepoint
The OLE DB provider "SQLNCLI10" for linked server indicates.
Mobile solar charger
Oracle to SQL Server replication
Cannot insert the value NULL into column
Undocumented Microsoft SQL Server 2008
VMware
Zoekmachine optimalisatie
SQL Servers hidden objects
FckEditor
Flash in Ajax
De hype die AJAX heet
Barcode scannen
MySQL; Gratis, makkelijk en snel!
PHP
sIFR; de combinatie tussen HTML en Flash