Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSrefresh_publisher_idrange

  No additional text.


Syntax
-- this proc will refresh the local publisher's range
create procedure sys.sp_MSrefresh_publisher_idrange
    @qualified_object_name nvarchar(517),
    @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,  -- 0=none needed, 1=one range needed, 2=both ranges needed
    @refresh_check_constraint bit
as
    declare @range_begin numeric(38,0)
    declare @range_end numeric(38,0)
    declare @next_range_begin numeric(38,0)
    declare @next_range_end numeric(38,0)
    declare @retcode int

    exec @retcode = sys.sp_MSreplcheck_publish
    if @@error<>0 or @retcode<>0
        return 1

    if @ranges_needed=0
        return 0

    if @artid is NULL
    begin
        select @artid=artid from dbo.sysmergearticles where objid=object_id(@qualified_object_name)
        if @artid is NULL
        begin
            RAISERROR (20027, 16, -1, @qualified_object_name)
            RETURN (1)
        end
    end

    select @range_begin = range_begin,
           @range_end = range_end,
           @next_range_begin = next_range_begin,
           @next_range_end = next_range_end
        from dbo.MSmerge_identity_range where artid=@artid and subid=@subid and is_pub_range=0

    exec @retcode = sys.sp_MSget_new_idrange
                            @qualified_object_name,
                            @artid,
                            @range_begin output,
                            @range_end output,
                            @next_range_begin output,
                            @next_range_end output,
                            2, -- subscriber range. This is the publisher's local range.
                            @ranges_needed
    if @@error<>0 or @retcode<>0
    begin
        raiserror(21197, 16, -1)
        return 1
    end

    if @refresh_check_constraint=1 and @qualified_object_name is not NULL
    begin
        exec @retcode = sys.sp_MSrefresh_idrange_check_constraint @qualified_object_name, @artid, @range_begin, @range_end, @next_range_begin, @next_range_end, @ranges_needed
        if @@error<>0 or @retcode<>0
        begin
            raiserror(21197, 16, -1)
            return 1
        end
    end

    update dbo.MSmerge_identity_range
        set range_begin = @range_begin,
            range_end = @range_end,
            next_range_begin = @next_range_begin,
            next_range_end = @next_range_end
        where subid=@subid and artid=@artid and is_pub_range=0
    if @@ERROR<>0
    begin
        raiserror(21197, 16, -1)
        return 1
    end

    -- also update on the distributor the identity range that was just allocated to the publisher
    -- we will do this only for the root publisher. When a republisher gets restored from backup
    -- it should merge with its root publisher to get the information on what ranges were allocated.
    exec @retcode = sys.sp_MSmerge_log_idrange_alloc_on_distributor
                        @subid,
                        @artid,
                        0, -- is_pub_range 0 because in Yukon publisher's local allocation is the size of the sub range.
                        @ranges_needed,
                        @range_begin,
                        @range_end,
                        @next_range_begin,
                        @next_range_end

    return 0

 
Last revision 2008RTM
See also

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