Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MScheck_publisher_range_refresh

  No additional text.


Syntax
-- this proc will check if the local publisher's range needs to be refreshed
-- this only works for root publisher and not for re-publishers
create procedure sys.sp_MScheck_publisher_range_refresh
    @qualified_table_name nvarchar(300),
    @subid uniqueidentifier,  -- pubid of the publisher whose range is to be refreshed.
    @artid uniqueidentifier,  -- though the artid can be derived from the @qualified_object_name, we will take it as a parameter to do one less query
    @ranges_needed tinyint output
as
    declare @retcode int
    declare @pub_range_begin numeric(38,0)
    declare @pub_range_end numeric(38,0)
    declare @pub_next_range_begin numeric(38,0)
    declare @pub_next_range_end numeric(38,0)
    declare @ident_current numeric(38,0)

    if (is_member('db_owner') <> 1)
    begin
        select @ranges_needed = 0
        return 0
    end

    if (sys.fn_MSmerge_isrepublisher(@artid) = 1)
    begin
        select @ranges_needed = 0
        return 0
    end

    select @ranges_needed = 0
    select @ident_current = IDENT_CURRENT(@qualified_table_name)

    select @pub_range_begin = range_begin,
           @pub_range_end = range_end,
           @pub_next_range_begin = next_range_begin,
           @pub_next_range_end = next_range_end
        from dbo.MSmerge_identity_range where artid=@artid and is_pub_range=0 and subid = @subid
    if IDENT_INCR(@qualified_table_name)>0
    begin
        if @ident_current >= @pub_next_range_end
        begin
            select @ranges_needed = 2
        end
        else if @ident_current >= @pub_range_end
        begin
            if @ident_current < @pub_next_range_begin
                DBCC CHECKIDENT (@qualified_table_name, RESEED, @pub_next_range_begin) with no_infomsgs
            select @ranges_needed = 1
        end
        else if @ident_current is NULL or @ident_current <= @pub_range_end
        begin
            select @ranges_needed = 0
        end
    end
    else
    begin
        if @ident_current <= @pub_next_range_end
        begin
            select @ranges_needed = 2
        end
        else if @ident_current <= @pub_range_end
        begin
            if @ident_current > @pub_next_range_begin
                DBCC CHECKIDENT (@qualified_table_name, RESEED, @pub_next_range_begin) with no_infomsgs
            select @ranges_needed = 1
        end
        else if @ident_current is NULL or @ident_current >= @pub_range_end
        begin
            select @ranges_needed = 0
        end
    end

    -- @pub_next_range_begin and @pub_next_range_end will be NULL after upgrade
    -- hence in that case we will request one range
    if @pub_next_range_begin is NULL or @pub_next_range_end is NULL
    begin
        select @ranges_needed = 1
        select @pub_next_range_begin = @pub_range_begin
        select @pub_next_range_end = @pub_range_end
        update dbo.MSmerge_identity_range
            set next_range_begin = @pub_next_range_begin,
                next_range_end = @pub_next_range_end
            where artid=@artid and is_pub_range=0 and subid = @subid
    end

    return 0


 
Last revision 2008RTM
See also

  sp_MSallocate_new_identity_range (Procedure)
sp_MSdrop_rladmin (Procedure)
sp_MSsetup_publisher_idrange (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