Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MScheck_autoident_parameters

  No additional text.


Syntax
create procedure sys.sp_MScheck_autoident_parameters
    @qualified_name nvarchar(300),
    @pub_identity_range bigint = NULL,
    @identity_range bigint = NULL,
    @threshold  int = NULL
as

    declare @objid int
    declare @ident_incr numeric(38,0)
    declare @max_range numeric(38,0)
    declare @min_range numeric(38,0)
    declare @retcode int
    declare @ident_incr_str nvarchar(100)
    declare @identity_column sysname

    select @objid = object_id(@qualified_name)

    if OBJECTPROPERTY(@objid, 'tablehasidentity') <> 1
    begin
        raiserror(21194, 16, -1)
        return (1)
    end

    -- we will not allow auto identity range for tinyint
    if exists (select 1 from sys.columns where object_id = object_id(@qualified_name) and is_identity=1 and system_type_id=48)
    begin
        raiserror(20704, 16 ,-1, @qualified_name)
        return 1
    end

    if @pub_identity_range <= 1 or @identity_range <= 1
    begin
        raiserror(21232, 16 ,-1)
        return 1
    end

    if @threshold is not NULL and (@threshold<1 OR @threshold>100)
    begin
        raiserror(21241, 16, -1)
        return (1)
    end

    select @ident_incr = IDENT_INCR(@qualified_name)
    select @ident_incr_str = convert(nvarchar(100), @ident_incr)
    select @identity_column = name from sys.columns where object_id = @objid and is_identity = 1

    -- publisher identity range and identity range should be a multiple of ident_incr of the identity column
    if (@pub_identity_range%@ident_incr) <> 0
    begin
        raiserror(20657, 16, -1, @qualified_name, @identity_column, @ident_incr_str)
        return (1)
    end

    if (@identity_range%@ident_incr) <> 0
    begin
        raiserror(20658, 16, -1, @qualified_name, @identity_column, @ident_incr_str)
        return (1)
    end

    exec @retcode = sys.sp_MScompute_maxmin_identity @objid, @max_range output, @min_range output
    if @retcode<>0 or @@error<>0
        return 1

    if @pub_identity_range>=@max_range or
       @pub_identity_range + @identity_range > @max_range
    begin
        raiserror(21290, 16, -1)
        return (1)
    end

    if (@ident_incr > 0)
    begin
        if (@pub_identity_range + @identity_range) > (@max_range - ISNULL(IDENT_CURRENT(@qualified_name), IDENT_SEED(@qualified_name)))
        begin
            raiserror(21290, 16, -1)
            return (1)
        end
    end
    else
    begin
        if -(@pub_identity_range + @identity_range) < (@min_range - ISNULL(IDENT_CURRENT(@qualified_name), IDENT_SEED(@qualified_name)))
        begin
            raiserror(21290, 16, -1)
            return (1)
        end
    end


 
Last revision 2008RTM
See also

  sp_addmergearticle (Procedure)
sp_changemergearticle (Procedure)
sp_MSdrop_rladmin (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