INDEXPROPERTY (Transact-SQL)

 

THIS TOPIC APPLIES TO: yesSQL Server (starting with 2008)yesAzure SQL DatabaseyesAzure SQL Data Warehouse yesParallel Data Warehouse

Returns the named index or statistics property value of a specified table identification number, index or statistics name, and property name. Returns NULL for XML indexes.

Topic link icon Transact-SQL Syntax Conventions

-- Syntax for SQL Server, Azure SQL Database, Azure SQL Data Warehouse, Parallel Data Warehouse  
  
INDEXPROPERTY ( object_ID , index_or_statistics_name , property )   

object_ID
Is an expression that contains the object identification number of the table or indexed view for which to provide index property information. object_ID is int.

index_or_statistics_name
Is an expression that contains the name of the index or statistics for which to return property information. index_or_statistics_name is nvarchar(128).

property
Is an expression that contains the name of the database property to return. property is varchar(128), and can be one of these values.

System_CAPS_ICON_note.jpg Note


Unless noted otherwise, NULL is returned when property is not a valid property name, object_ID is not a valid object ID, object_ID is an unsupported object type for the specified property, or the caller does not have permission to view the object's metadata.

PropertyDescriptionValue
IndexDepthDepth of the index.Number of index levels.

NULL = XML index or input is not valid.
IndexFillFactorFill factor value used when the index was created or last rebuilt.Fill factor
IndexIDIndex ID of the index on a specified table or indexed view.Index ID
IsAutoStatisticsStatistics were generated by the AUTO_CREATE_STATISTICS option of ALTER DATABASE.1 = True

0 = False or XML index.
IsClusteredIndex is clustered.1 = True

0 = False or XML index.
IsDisabledIndex is disabled.1 = True

0 = False

NULL = Input is not valid.
IsFulltextKeyIndex is the full-text and semantic indexing key for a table.Applies to: SQL Server 2008 through SQL Server 2016.

1 = True

0 = False or XML index.

NULL = Input is not valid.
IsHypotheticalIndex is hypothetical and cannot be used directly as a data access path. Hypothetical indexes hold column-level statistics and are maintained and used by Database Engine Tuning Advisor.1 = True

0 = False or XML index

NULL = Input is not valid.
IsPadIndexIndex specifies space to leave open on each interior node.Applies to: SQL Server 2008 through SQL Server 2016.

1 = True

0 = False or XML index.
IsPageLockDisallowedPage-locking value set by the ALLOW_PAGE_LOCKS option of ALTER INDEX.Applies to: SQL Server 2008 through SQL Server 2016.

1 = Page locking is disallowed.

0 = Page locking is allowed.

NULL = Input is not valid.
IsRowLockDisallowedRow-locking value set by the ALLOW_ROW_LOCKS option of ALTER INDEX.Applies to: SQL Server 2008 through SQL Server 2016.

1 = Row locking is disallowed.

0 = Row locking is allowed.

NULL = Input is not valid.
IsStatisticsindex_or_statistics_name is statistics created by the CREATE STATISTICS statement or by the AUTO_CREATE_STATISTICS option of ALTER DATABASE.1 = True

0 = False or XML index.
IsUniqueIndex is unique.1 = True

0 = False or XML index.
IsColumnstoreIndex is an xVelocity memory optimized columnstore index.Applies to: SQL Server 2012 through SQL Server 2016.

1 = True

0 = False

int

Returns NULL on error or if a caller does not have permission to view the object.

A user can only view the metadata of securables that the user owns or on which the user has been granted permission. This means that metadata-emitting, built-in functions such as INDEXPROPERTY may return NULL if the user does not have any permission on the object. For more information, see Metadata Visibility Configuration.

The following example returns the values for the IsClustered, IndexDepth, and IndexFillFactor properties for the PK_Employee_BusinessEntityID index of the Employee table in the AdventureWorks2012 database.

SELECT   
    INDEXPROPERTY(OBJECT_ID('HumanResources.Employee'),  
        'PK_Employee_BusinessEntityID','IsClustered')AS [Is Clustered],  
    INDEXPROPERTY(OBJECT_ID('HumanResources.Employee'),  
        'PK_Employee_BusinessEntityID','IndexDepth') AS [Index Depth],  
    INDEXPROPERTY(OBJECT_ID('HumanResources.Employee'),  
        'PK_Employee_BusinessEntityID','IndexFillFactor') AS [Fill Factor];  
  

Here is the result set:

Is Clustered Index Depth Fill Factor   
------------ ----------- -----------   
1            2           0  
  
(1 row(s) affected)  

The following example examines the properties of one of the indexes on the FactResellerSales table.

-- Uses AdventureWorks  
  
SELECT   
INDEXPROPERTY(OBJECT_ID('dbo.FactResellerSales'),  
    'ClusteredIndex_6d10fa223e5e4c1fbba087e29e16a7a2','IsClustered') AS [Is Clustered],  
INDEXPROPERTY(OBJECT_ID('dbo.FactResellerSales'),  
    'ClusteredIndex_6d10fa223e5e4c1fbba087e29e16a7a2','IsColumnstore') AS [Is Columnstore Index],  
INDEXPROPERTY(OBJECT_ID('dbo.FactResellerSales'),  
    'ClusteredIndex_6d10fa223e5e4c1fbba087e29e16a7a2','IndexFillFactor') AS [Fill Factor];  
GO  

CREATE INDEX (Transact-SQL)
Statistics
sys.indexes (Transact-SQL)
sys.index_columns (Transact-SQL)
sys.stats (Transact-SQL)
sys.stats_columns (Transact-SQL)

Community Additions

ADD
Show: