Skip to content

Latest commit

 

History

History
75 lines (49 loc) · 3.34 KB

modify-an-index.md

File metadata and controls

75 lines (49 loc) · 3.34 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic helpviewer_keywords monikerRange
Modify an Index
Modify an Index
MikeRayMSFT
mikeray
02/17/2017
sql
table-view-index
conceptual
indexes [SQL Server], modifying
modifying indexes
index changes [SQL Server]
=azuresqldb-current||>=sql-server-2016

Modify an Index

[!INCLUDE SQL Server Azure SQL Database Azure SQL Managed Instance]

This topic describes how to modify an index in [!INCLUDEssnoversion] by using [!INCLUDEssManStudioFull] or [!INCLUDEtsql].

Important

Indexes created as the result of a PRIMARY KEY or UNIQUE constraint cannot be modified by using this method. Instead, the constraint must be modified.

In This Topic

Using SQL Server Management Studio

To modify an index

  1. In Object Explorer, connect to an instance of the [!INCLUDEssDEnoversion] and then expand that instance.

  2. Expand Databases, expand the database in which the table belongs, and then expand Tables.

  3. Expand the table in which the index belongs and then expand Indexes.

  4. Right-click the index that you want to modify and then click Properties.

  5. In the Index Properties dialog box, make the desired changes. For example, you can add or remove a column from the index key, or change the setting of an index option.

To modify index columns

  1. To add, remove, or change the position of an index column, select the General page from the Index Properties dialog box.

Using Transact-SQL

To modify an index

The following example drops and re-creates an existing index on the ProductID column of the Production.WorkOrder table in the AdventureWorks database by using the DROP_EXISTING option. The options FILLFACTOR and PAD_INDEX are also set.

:::code language="sql" source="codesnippet/tsql/modify-an-index_1.sql":::

The following example uses ALTER INDEX to set several options on the index AK_SalesOrderHeader_SalesOrderNumber.

:::code language="sql" source="codesnippet/tsql/modify-an-index_2.sql":::

To modify index columns

  1. To add, remove, or change the position of an index column, you must drop and recreate the index.

See Also

CREATE INDEX (Transact-SQL)
ALTER INDEX (Transact-SQL)
INDEXPROPERTY (Transact-SQL)
sys.indexes (Transact-SQL)
sys.index_columns (Transact-SQL)
Set Index Options
Rename Indexes