Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSmerge_log_idrange_alloc_on_distributor

  No additional text.


Syntax
-- this proc will log the information about the identity range allocated on the
-- distributor. That information can later be used to catch up the publisher in case
-- of a backup restore.
create procedure sys.sp_MSmerge_log_idrange_alloc_on_distributor
    @subid uniqueidentifier,
    @artid uniqueidentifier,
    @is_pub_range bit,
    @ranges_allocated tinyint,  -- 0, 1 or 2
    @range_begin numeric(38,0),
    @range_end numeric(38,0),
    @next_range_begin numeric(38,0),
    @next_range_end numeric(38,0),
    @publication sysname = NULL,
    @subscriber sysname = NULL,
    @subscriber_db sysname = NULL

as
    declare @distributor sysname
    declare @distribdb sysname
    declare @article sysname
    declare @pubid uniqueidentifier
    declare @dbname sysname
    declare @retcode int
    declare @distproc nvarchar(350)
    			,@publishingservername sysname

    -- if this is the first allocation and we don't know of this subscription yet.
    -- Raise an error if the @publication, @subscriber and @subscriber_db parameters are also NULL
    select @pubid = pubid from dbo.sysmergesubscriptions where subid = @subid
    select @publishingservername = publishingservername()
    if @pubid is NULL
    begin
        -- even if subid is not correct atleast a valid subscriber db, publication information should have been specified.
        if @publication is NULL
        begin
            RAISERROR (21055, 16, -1, '@subid', 'sys.sp_MSmerge_log_idrange_alloc_on_distributor')
            RETURN (1)
        end
        if @subscriber is NULL
        begin
            RAISERROR (21055, 16, -1, '@subscriber', 'sys.sp_MSmerge_log_idrange_alloc_on_distributor')
            RETURN (1)
        end

        if @subscriber_db is NULL
        begin
            RAISERROR (21055, 16, -1, '@subscriber_db', 'sys.sp_MSmerge_log_idrange_alloc_on_distributor')
            RETURN (1)
        end
        select @pubid = pubid from dbo.sysmergepublications where name = @publication and publisher = publishingservername() and publisher_db = db_name()
        if @pubid is NULL
        begin
            RAISERROR (21055, 16, -1, '@publication', 'sys.sp_MSmerge_log_idrange_alloc_on_distributor')
            RETURN (1)
        end
    end
    else
    begin
        select @subscriber = subscriber_server, @subscriber_db = db_name from dbo.sysmergesubscriptions where subid = @subid
        select @publication = name from dbo.sysmergepublications where pubid = @pubid
    end

    select @article = name from dbo.sysmergearticles where pubid = @pubid and artid = @artid
    if @article is NULL
    begin
        RAISERROR (21055, 16, -1, '@artid', 'sys.sp_MSmerge_log_idrange_alloc_on_distributor')
        RETURN (1)
    end

    exec @retcode = sys.sp_helpdistributor @rpcsrvname = @distributor OUTPUT, @distribdb = @distribdb OUTPUT
    if @@error <> 0 OR @retcode <> 0
    BEGIN
        RAISERROR (14071, 16, -1)
        RETURN (1)
    END

    set @dbname = DB_NAME()
    SELECT @distproc = QUOTENAME(RTRIM(@distributor)) + '.' + QUOTENAME(@distribdb) + '.dbo.sp_MSmerge_log_identity_range_allocations'
    EXECUTE @retcode = @distproc
        @publisher = @publishingservername,
        @publisher_db = @dbname,
        @publication = @publication,
        @article = @article,
        @subscriber = @subscriber,
        @subscriber_db = @subscriber_db,
        @is_pub_range = @is_pub_range,
        @ranges_allocated = @ranges_allocated,
        @range_begin = @range_begin,
        @range_end = @range_end,
        @next_range_begin = @next_range_begin,
        @next_range_end = @next_range_end

    IF @@ERROR <> 0 or @retcode <> 0
        RETURN(1)

 
Last revision 2008RTM
See also

  sp_MSadjustmergeidentity (Procedure)
sp_MSallocate_new_identity_range (Procedure)
sp_MSdrop_rladmin (Procedure)
sp_MSfetchidentityrange (Procedure)
sp_MSrefresh_publisher_idrange (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