Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MScheckidentityrange

  No additional text.


Syntax

create procedure sys.sp_MScheckidentityrange
    @pubid              uniqueidentifier,
    @artname            sysname,
    @next_seed          bigint,
    @range              bigint,
    @threshold          int,
    @checkonly          int
AS
    declare @colid              int
    declare @colname            sysname
    declare @retcode            int
    declare @objid              int
    declare @identity_so_far    bigint
    declare @current_max        bigint
    declare @max_identity       bigint
    declare @tablename          sysname
    declare @pub_range          bigint
    declare @lightweight                bit

        /*
        ** Check to see if current publication has permission
        */
        if ({ fn ISPALUSER(@pubid)} <> 1)
        begin
                RAISERROR (14126, 11, -1)
                return (1)
        end

    -- this proc will never be called in yukon except for light weight subscribers
        set @lightweight=sys.fn_MSuselightweightreplication(null, null, null, @pubid, null, null, null)
        if @lightweight = 0
        begin
            raiserror('sp_MScheckidentityrange should not have been called', 16, -1)
            return 1
        end

    select @objid = objid from dbo.sysmergearticles where pubid=@pubid and name=@artname
    if @objid is NULL
        begin
            raiserror(20027, 16, -1, @artname)
            return 1
        end

    select @tablename=object_name(@objid)

        begin tran
    save TRAN sp_MScheckidentityrange

        if @checkonly=1
        begin
                select @max_identity= max_identity from MSmerge_idrange where objid=@objid
                if @max_identity is null goto FAILURE

                set @identity_so_far= isnull(ident_current(@tablename), ident_seed(@tablename))
                select case
                        when (@max_identity - @identity_so_far) * 100 / @range < (100 - @threshold) then 1 -- needs bump up
                        else 0 -- no need to bump up
                end
        end
    else
    begin
        update MSmerge_idrange set max_identity=@next_seed + @range
                where objid = @objid

        exec sys.sp_MSreseed @objid, @next_seed, @range
        if @@ERROR <> 0
            goto FAILURE
    end

        commit tran
        return 0

FAILURE:
   select 0
        if @@TRANCOUNT > 0
    begin
        ROLLBACK TRAN sp_MScheckidentityrange
        COMMIT TRAN
    end
    return(1)

 
Last revision 2008RTM
See also

  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