Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSsetlastsentgen

  No additional text.


Syntax

CREATE PROCEDURE sys.sp_MSsetlastsentgen
    (@repid uniqueidentifier, @srcgen bigint, @srcguid uniqueidentifier)
as
    /*
    ** Check to see if current publication has permission
    */
    declare @retcode    int
    declare @pubid      uniqueidentifier
    declare @subscription_type smallint

    -- if this is the light weight client we have nothing to set here
    if object_id('dbo.MSmerge_rowtrack', 'U') is not null
        return 0

    exec @retcode = sys.sp_MSrepl_PAL_rolecheck @repid = @repid
    if (@retcode <> 0) or (@@error <> 0)
        return 1

    if (@repid is null)
    begin
        RAISERROR(14043, 16, -1, '@repid', 'sp_MSsetlastsentgen')
        return (1)
    end

    if object_id('MSmerge_contents') is NULL
    begin
        RAISERROR(20054 , 16, -1)
        return (1)
    end

    /*
    ** This is a special case which is used to update the anonymous subscriptions sent and
    ** received generation guids at the end of initializing a dynamic subscription. This is
    ** used in the case where an anonymous subscription is reinitialized after a merge metadata
    ** cleanup
    */
    if (@srcgen is null and @srcguid is null)
    begin

        declare @lastrecsentgen     bigint
        declare @lastrecsentguid    uniqueidentifier

        select @lastrecsentgen = max(g.generation)
            from MSmerge_genhistory g,
            (select isnull(gen2.generation, gen1.generation) as generation
                from (select max(generation) as generation from dbo.MSmerge_genhistory where genstatus in (1,2)) as gen1,
                        (select min(generation) as generation from dbo.MSmerge_genhistory where genstatus in (0,4)) as gen2
            ) as minopengen
        where g.generation <= minopengen.generation and g.genstatus in (1,2)
        if @lastrecsentgen IS NOT NULL
            select @lastrecsentguid = guidsrc from dbo.MSmerge_genhistory where generation = @lastrecsentgen
        update dbo.sysmergesubscriptions  set sentgen= @lastrecsentgen, sentguid = @lastrecsentguid
            where subid = @repid
        IF @@ERROR <>0 return (1)
    end
    else
    begin
        -- check for setting a sentgen which is obviously too high
        if (exists (select * from dbo.MSmerge_genhistory where generation < @srcgen and
                    genstatus in (0,4) and
                    (art_nick = 0 or art_nick is null or art_nick in
                        (select nickname from dbo.sysmergearticles where
                                pubid = @pubid) )))
        begin
            RAISERROR('Setting sentgen too high', 16, -1)
            return (1)
        end
        update dbo.sysmergesubscriptions  set sentgen= @srcgen, sentguid = @srcguid
            where subid = @repid
        IF @@ERROR <>0 return (1)
    end
    return (0)

 
Last revision 2008RTM
See also

  sp_MScomputelastsentgen (Procedure)
sp_MSdrop_rlrecon (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