Skip to content

Commit a283cdb

Browse files
authored
Merge pull request #35701 from rwestMSFT/rw-1031-fix-10206
Refresh INDEXPROPERTY article (PR 10206)
2 parents c4ca6bf + 08c468e commit a283cdb

1 file changed

Lines changed: 103 additions & 100 deletions

File tree

Lines changed: 103 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
---
22
title: "INDEXPROPERTY (Transact-SQL)"
3-
description: "INDEXPROPERTY (Transact-SQL)"
3+
description: Returns the named property value of a specified table identification number, index or statistics name, and property name.
44
author: markingmyname
55
ms.author: maghan
6-
ms.date: 06/26/2019
6+
ms.reviewer: randolphwest
7+
ms.date: 10/31/2025
78
ms.service: sql
89
ms.subservice: t-sql
910
ms.topic: reference
@@ -15,108 +16,110 @@ helpviewer_keywords:
1516
- "indexes [SQL Server], viewing"
1617
- "indexes [SQL Server], properties"
1718
dev_langs:
18-
- "TSQL"
19-
monikerRange: ">= aps-pdw-2016 || = azuresqldb-current || = azure-sqldw-latest || >= sql-server-2016 || >= sql-server-linux-2017 || = azuresqldb-mi-current"
19+
- TSQL
20+
monikerRange: ">=aps-pdw-2016 || =azuresqldb-current || =azure-sqldw-latest || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current"
2021
---
2122
# INDEXPROPERTY (Transact-SQL)
23+
2224
[!INCLUDE [sql-asdb-asdbmi-asa-pdw](../../includes/applies-to-version/sql-asdb-asdbmi-asa-pdw.md)]
2325

24-
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.
25-
26-
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: [Transact-SQL syntax conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md)
27-
28-
## Syntax
29-
30-
```syntaxsql
31-
INDEXPROPERTY ( object_ID , index_or_statistics_name , property )
32-
```
33-
26+
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.
27+
28+
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: [Transact-SQL syntax conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md)
29+
30+
## Syntax
31+
32+
```syntaxsql
33+
INDEXPROPERTY ( object_ID , index_or_statistics_name , property )
34+
```
35+
3436
## Arguments
35-
*object_ID*
36-
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**.
37-
38-
*index_or_statistics_name*
39-
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)**.
40-
41-
*property*
42-
Is an expression that contains the name of the database property to return. *property* is **varchar(128)**, and can be one of these values.
43-
37+
38+
#### *object_ID*
39+
40+
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**.
41+
42+
#### *index_or_statistics_name*
43+
44+
An expression that contains the name of the index or statistics for which to return property information. *index_or_statistics_name* is **nvarchar(128)**.
45+
46+
#### *property*
47+
48+
An expression that contains the name of the index or statistics property to return. *property* is **varchar(128)**, and can be one of these values.
49+
4450
> [!NOTE]
45-
> 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.
46-
47-
|Property|Description|Value|
48-
|--------------|-----------------|-----------|
49-
|**IndexDepth**|Depth of the index.|Number of index levels.<br /><br /> NULL = XML index or input is not valid.|
50-
|**IndexFillFactor**|Fill factor value used when the index was created or last rebuilt.|Fill factor|
51-
|**IndexID**|Index ID of the index on a specified table or indexed view.|Index ID|
52-
|**IsAutoStatistics**|Statistics were generated by the AUTO_CREATE_STATISTICS option of ALTER DATABASE.|1 = True<br /><br /> 0 = False or XML index.|
53-
|**IsClustered**|Index is clustered.|1 = True<br /><br /> 0 = False or XML index.|
54-
|**IsDisabled**|Index is disabled.|1 = True<br /><br /> 0 = False<br /><br /> NULL = Input is not valid.|
55-
|**IsFulltextKey**|Index is the full-text and semantic indexing key for a table.|**Applies to**: [!INCLUDE[sql2008-md](../../includes/sql2008-md.md)] and later.<br /><br /> 1 = True<br /><br /> 0 = False or XML index.<br /><br /> NULL = Input is not valid.|
56-
|**IsHypothetical**|Index 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<br /><br /> 0 = False or XML index<br /><br /> NULL = Input is not valid.|
57-
|**IsPadIndex**|Index specifies space to leave open on each interior node.|**Applies to**: [!INCLUDE[sql2008-md](../../includes/sql2008-md.md)] and later.<br /><br /> 1 = True<br /><br /> 0 = False or XML index.|
58-
|**IsPageLockDisallowed**|Page-locking value set by the ALLOW_PAGE_LOCKS option of ALTER INDEX.|**Applies to**: [!INCLUDE[sql2008-md](../../includes/sql2008-md.md)] and later.<br /><br /> 1 = Page locking is disallowed.<br /><br /> 0 = Page locking is allowed.<br /><br /> NULL = Input is not valid.|
59-
|**IsRowLockDisallowed**|Row-locking value set by the ALLOW_ROW_LOCKS option of ALTER INDEX.|**Applies to**: [!INCLUDE[sql2008-md](../../includes/sql2008-md.md)] and later.<br /><br /> 1 = Row locking is disallowed.<br /><br /> 0 = Row locking is allowed.<br /><br /> NULL = Input is not valid.|
60-
|**IsStatistics**|*index_or_statistics_name* is statistics created by the CREATE STATISTICS statement or by the AUTO_CREATE_STATISTICS option of ALTER DATABASE.|1 = True<br /><br /> 0 = False or XML index.|
61-
|**IsUnique**|Index is unique.|1 = True<br /><br /> 0 = False or XML index.|
62-
|**IsColumnstore**|Index is an xVelocity memory optimized columnstore index.|**Applies to**: [!INCLUDE[ssSQL11](../../includes/sssql11-md.md)] and later.<br /><br /> 1 = True<br /><br /> 0 = False|
63-
|**IsOptimizedForSequentialKey**|Index has optimization for last-page inserts enabled.|**Applies to**: [!INCLUDE[sql-server-2019](../../includes/sssql19-md.md)] and later. <br><br>1 = True<br><br>0 = False|
64-
65-
## Return Types
66-
**int**
67-
68-
## Exceptions
69-
Returns NULL on error or if a caller does not have permission to view the object.
70-
71-
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](../../relational-databases/security/metadata-visibility-configuration.md).
72-
73-
## Examples
74-
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 [!INCLUDE[ssSampleDBnormal](../../includes/sssampledbnormal-md.md)] database.
75-
76-
```sql
77-
SELECT
78-
INDEXPROPERTY(OBJECT_ID('HumanResources.Employee'),
79-
'PK_Employee_BusinessEntityID','IsClustered')AS [Is Clustered],
80-
INDEXPROPERTY(OBJECT_ID('HumanResources.Employee'),
81-
'PK_Employee_BusinessEntityID','IndexDepth') AS [Index Depth],
82-
INDEXPROPERTY(OBJECT_ID('HumanResources.Employee'),
83-
'PK_Employee_BusinessEntityID','IndexFillFactor') AS [Fill Factor];
84-
85-
```
86-
87-
Here is the result set:
88-
89-
```
90-
Is Clustered Index Depth Fill Factor
91-
------------ ----------- -----------
92-
1 2 0
93-
94-
(1 row(s) affected)
95-
```
96-
97-
## Examples: [!INCLUDE[ssazuresynapse-md](../../includes/ssazuresynapse-md.md)] and [!INCLUDE[ssPDW](../../includes/sspdw-md.md)]
98-
The following example examines the properties of one of the indexes on the `FactResellerSales` table.
99-
100-
```sql
101-
-- Uses AdventureWorks
102-
103-
SELECT
104-
INDEXPROPERTY(OBJECT_ID('dbo.FactResellerSales'),
105-
'ClusteredIndex_6d10fa223e5e4c1fbba087e29e16a7a2','IsClustered') AS [Is Clustered],
106-
INDEXPROPERTY(OBJECT_ID('dbo.FactResellerSales'),
107-
'ClusteredIndex_6d10fa223e5e4c1fbba087e29e16a7a2','IsColumnstore') AS [Is Columnstore Index],
108-
INDEXPROPERTY(OBJECT_ID('dbo.FactResellerSales'),
109-
'ClusteredIndex_6d10fa223e5e4c1fbba087e29e16a7a2','IndexFillFactor') AS [Fill Factor];
110-
GO
111-
```
112-
113-
## See Also
114-
[CREATE INDEX &#40;Transact-SQL&#41;](../../t-sql/statements/create-index-transact-sql.md)
115-
[Statistics](../../relational-databases/statistics/statistics.md)
116-
[sys.indexes &#40;Transact-SQL&#41;](../../relational-databases/system-catalog-views/sys-indexes-transact-sql.md)
117-
[sys.index_columns &#40;Transact-SQL&#41;](../../relational-databases/system-catalog-views/sys-index-columns-transact-sql.md)
118-
[sys.stats &#40;Transact-SQL&#41;](../../relational-databases/system-catalog-views/sys-stats-transact-sql.md)
119-
[sys.stats_columns &#40;Transact-SQL&#41;](../../relational-databases/system-catalog-views/sys-stats-columns-transact-sql.md)
120-
121-
51+
> Unless noted otherwise, `NULL` is returned when *property* isn't a valid property name, *object_ID* isn't a valid object ID, *object_ID* is an unsupported object type for the specified property, or the caller doesn't have permission to view the object's metadata.
52+
53+
| Property | Description | Value |
54+
| --- | --- | --- |
55+
| `IndexDepth` | Depth of the index. | Number of index levels.<br /><br />`NULL` = XML index or input isn't valid. |
56+
| `IndexFillFactor` | Fill factor value used when the index was created or last rebuilt. | Fill factor |
57+
| `IndexID` | Index ID of the index on a specified table or indexed view. | Index ID |
58+
| `IsAutoStatistics` | Statistics were generated by the `AUTO_CREATE_STATISTICS` option of `ALTER DATABASE`. | `1` = True<br />`0` = False or XML index. |
59+
| `IsClustered` | Index is clustered. | `1` = True<br />`0` = False or XML index. |
60+
| `IsDisabled` | Index is disabled. | `1` = True<br />`0` = False<br />`NULL` = Input isn't valid. |
61+
| `IsFulltextKey` | Index is the full-text and semantic indexing key for a table. | `1` = True<br />`0` = False or XML index.<br />`NULL` = Input isn't valid. |
62+
| `IsHypothetical` | Index is hypothetical and can't 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<br />`0` = False or XML index<br />`NULL` = Input isn't valid. |
63+
| `IsPadIndex` | Index specifies space to leave open on each interior node. | `1` = True<br />`0` = False or XML index. |
64+
| `IsPageLockDisallowed` | Page-locking value set by the `ALLOW_PAGE_LOCKS` option of `ALTER INDEX`. | `1`&nbsp;=&nbsp;Page&nbsp;locking&nbsp;is&nbsp;disallowed.<br />`0` = Page locking is allowed.<br />`NULL` = Input isn't valid. |
65+
| `IsRowLockDisallowed` | Row-locking value set by the `ALLOW_ROW_LOCKS` option of `ALTER INDEX`. | `1` = Row locking is disallowed.<br />`0` = Row locking is allowed.<br />`NULL` = Input isn't valid. |
66+
| `IsStatistics` | *index_or_statistics_name* is statistics created by the `CREATE STATISTICS` statement or by the `AUTO_CREATE_STATISTICS` option of `ALTER DATABASE`. | `1` = True<br />`0` = False or XML index. |
67+
| `IsUnique` | Index is unique. | `1` = True<br />`0` = False or XML index. |
68+
| `IsColumnstore` | Index is a memory optimized columnstore index. | `1` = True<br />`0` = False<br /><br />**Applies to**: [!INCLUDE [ssSQL11](../../includes/sssql11-md.md)] and later versions. |
69+
| `IsOptimizedForSequentialKey` | Index has optimization for last-page inserts enabled. | `1` = True<br />`0` = False<br /><br />**Applies to**: [!INCLUDE [sql-server-2019](../../includes/sssql19-md.md)] and later versions. |
70+
71+
## Return types
72+
73+
**int**
74+
75+
## Exceptions
76+
77+
Returns `NULL` on error or if a caller doesn't have permission to view the object.
78+
79+
A user can only view the metadata of securables that the user owns or on which the user is granted permission. This means that metadata-emitting, built-in functions such as `INDEXPROPERTY` might return `NULL` if the user doesn't have any permission on the object. For more information, see [Metadata visibility configuration](../../relational-databases/security/metadata-visibility-configuration.md).
80+
81+
## Examples
82+
83+
[!INCLUDE [article-uses-adventureworks](../../includes/article-uses-adventureworks.md)]
84+
85+
### A. Return properties for index on Employee table
86+
87+
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 [!INCLUDE [ssSampleDBnormal](../../includes/sssampledbnormal-md.md)] database.
88+
89+
```sql
90+
SELECT
91+
INDEXPROPERTY(OBJECT_ID('HumanResources.Employee'), 'PK_Employee_BusinessEntityID', 'IsClustered') AS [Is Clustered],
92+
INDEXPROPERTY(OBJECT_ID('HumanResources.Employee'), 'PK_Employee_BusinessEntityID', 'IndexDepth') AS [Index Depth],
93+
INDEXPROPERTY(OBJECT_ID('HumanResources.Employee'), 'PK_Employee_BusinessEntityID', 'IndexFillFactor') AS [Fill Factor];
94+
```
95+
96+
[!INCLUDE [ssresult-md](../../includes/ssresult-md.md)]
97+
98+
```output
99+
Is Clustered Index Depth Fill Factor
100+
------------ ----------- -----------
101+
1 2 0
102+
```
103+
104+
## Examples: Azure Synapse Analytics and Analytics Platform System (PDW)
105+
106+
### B. Return properties for index on FactResellerSales table
107+
108+
The following example examines the properties of one of the indexes on the `FactResellerSales` table.
109+
110+
```sql
111+
SELECT
112+
INDEXPROPERTY(OBJECT_ID('dbo.FactResellerSales'), 'ClusteredIndex_6d10fa223e5e4c1fbba087e29e16a7a2','IsClustered') AS [Is Clustered],
113+
INDEXPROPERTY(OBJECT_ID('dbo.FactResellerSales'), 'ClusteredIndex_6d10fa223e5e4c1fbba087e29e16a7a2','IsColumnstore') AS [Is Columnstore Index],
114+
INDEXPROPERTY(OBJECT_ID('dbo.FactResellerSales'), 'ClusteredIndex_6d10fa223e5e4c1fbba087e29e16a7a2','IndexFillFactor') AS [Fill Factor];
115+
GO
116+
```
117+
118+
## Related content
122119

120+
- [CREATE INDEX (Transact-SQL)](../statements/create-index-transact-sql.md)
121+
- [Statistics](../../relational-databases/statistics/statistics.md)
122+
- [sys.indexes (Transact-SQL)](../../relational-databases/system-catalog-views/sys-indexes-transact-sql.md)
123+
- [sys.index_columns (Transact-SQL)](../../relational-databases/system-catalog-views/sys-index-columns-transact-sql.md)
124+
- [sys.stats (Transact-SQL)](../../relational-databases/system-catalog-views/sys-stats-transact-sql.md)
125+
- [sys.stats_columns (Transact-SQL)](../../relational-databases/system-catalog-views/sys-stats-columns-transact-sql.md)

0 commit comments

Comments
 (0)