Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSmerge_getgencur

  No additional text.


Syntax

create procedure sys.sp_MSmerge_getgencur (
    @tablenick int, -- tablenick for gen
    @changecount int, -- number of changes to put in gen
    @gen_cur bigint output
)
as
begin
    set nocount on
    declare @gen_change_threshold int
    declare @max_changecount int
    --declare @GENSTATUS_OPEN tinyint
    declare @replnick binary(6)
    declare @nickbin varbinary(255)
    declare @retcode int

    select @gen_cur = NULL
    --select @GENSTATUS_OPEN = 0

    if @changecount is NULL
        select @changecount = 0

    exec @retcode= sys.sp_MSgetreplnick @replnick = @replnick out
    if @retcode<>0 or @@error<>0 return NULL

    -- add a guard byte
    set @nickbin= @replnick + 0xFF

    if (@changecount > 0)
    begin
        select @gen_change_threshold = min(isnull(generation_leveling_threshold,0)) from dbo.sysmergepublications
            where pubid in (select pubid from dbo.sysmergearticles where nickname = @tablenick)
        if @gen_change_threshold = 0
            select @max_changecount = NULL
        else
            select @max_changecount = @gen_change_threshold-@changecount

    end
    else
        select @max_changecount = NULL

    if @max_changecount is not NULL
        select top 1 @gen_cur = generation from dbo.MSmerge_genhistory with (updlock, readpast, rowlock)
            where genstatus = 0
                and changecount <= @max_changecount
                and art_nick = @tablenick
    else
        select top 1 @gen_cur = generation from dbo.MSmerge_genhistory with (updlock, readpast, rowlock)
            where genstatus = 0
                and art_nick = @tablenick

    if @gen_cur is NULL
    begin
        insert into dbo.MSmerge_genhistory with (rowlock)
            (guidsrc, genstatus, art_nick, nicknames, coldate, changecount)
              values  (newid(), 0, @tablenick, @nickbin, getdate(), 0)
        select @gen_cur = @@identity
    end

    return 0
end

 
Last revision 2008RTM
See also

  sp_addtabletocontents (Procedure)
sp_MSdrop_rlcore (Procedure)
sp_MSevaluate_logicalrecordparent (Procedure)
sp_MSevaluate_logicalrecordparent_allcontentsrows (Procedure)
sp_MSfixupbeforeimagetables (Procedure)
sp_MSinsertbeforeimageclause (Procedure)
sp_MSmakebatchinsertproc (Procedure)
sp_MSmerge_getgencur_public (Procedure)
sp_MSupdate_singlelogicalrecordmetadata (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