Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Applies to:
SQL Server
Azure SQL Database
Azure SQL Managed Instance
SQL database in Microsoft Fabric
This topic describes how to modify the properties of an index in SQL Server by using SQL Server Management Studio or Transact-SQL.
In This Article
Before you begin:
To modify the properties of an index, using:
Requires ALTER permission on the table or view.
The following example shows the properties of all indexes in a table in the AdventureWorks database.
SELECT i.name AS index_name
, i.type_desc
, i.is_unique
, ds.type_desc AS filegroup_or_partition_scheme
, ds.name AS filegroup_or_partition_scheme_name
, i.ignore_dup_key
, i.is_primary_key
, i.is_unique_constraint
, i.fill_factor
, i.is_padded
, i.is_disabled
, i.allow_row_locks
, i.allow_page_locks
, i.has_filter
, i.filter_definition
FROM sys.indexes AS i
INNER JOIN sys.data_spaces AS ds
ON i.data_space_id = ds.data_space_id
WHERE is_hypothetical = 0 AND i.index_id <> 0
AND i.object_id = OBJECT_ID('HumanResources.Employee')
;
The following examples set the properties of indexes in the AdventureWorks database.
ALTER INDEX AK_SalesOrderHeader_SalesOrderNumber ON
Sales.SalesOrderHeader
SET (
STATISTICS_NORECOMPUTE = ON,
IGNORE_DUP_KEY = ON,
ALLOW_PAGE_LOCKS = ON
)
;
ALTER INDEX ALL ON Production.Product
REBUILD WITH
(
FILLFACTOR = 80
, SORT_IN_TEMPDB = ON
, STATISTICS_NORECOMPUTE = ON
)
;
For more information, see ALTER INDEX (Transact-SQL).
Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register todayTraining
Module
Configure databases for optimal performance - Training
Configure databases for optimal performance