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 rename an index in SQL Server by using SQL Server Management Studio or Transact-SQL. Renaming an index replaces the current index name with the new name that you provide. The specified name must be unique within the table or view. For example, two tables can have an index named XPK_1, but the same table cannot have two indexes named XPK_1. You cannot create an index with the same name as an existing disabled index. Renaming an index does not cause the index to be rebuilt.
In This Topic
Before you begin:
To rename an index, using:
When you create a PRIMARY KEY or UNIQUE constraint on a table, an index with the same name as the constraint is automatically created for the table. Because index names must be unique within the table, you cannot create or rename an index to have the same name as an existing PRIMARY KEY or UNIQUE constraint on the table.
Requires ALTER permission on the index.
In Object Explorer, click the plus sign to expand the database that contains the table on which you want to rename an index.
Click the plus sign to expand the Tables folder.
Right-click the table on which you want to rename an index and select Design.
On the Table Designer menu, click Indexes/Keys.
Select the index you want to rename in the Selected Primary/Unique Key or Index text box.
In the grid, click Name and type a new name into the text box.
Click Close.
On the File menu, click Savetable_name.
In Object Explorer, click the plus sign to expand the database that contains the table on which you want to rename an index.
Click the plus sign to expand the Tables folder.
Click the plus sign to expand the table on which you want to rename an index.
Click the plus sign to expand the Indexes folder.
Right-click the index you want to rename and select Rename.
Type the index's new name and press Enter.
In Object Explorer, connect to an instance of Database Engine.
On the Standard bar, click New Query.
Copy and paste the following example into the query window and click Execute.
USE AdventureWorks2022;
GO
--Renames the IX_ProductVendor_VendorID index on the Purchasing.ProductVendor table to IX_VendorID.
EXEC sp_rename N'Purchasing.ProductVendor.IX_ProductVendor_VendorID', N'IX_VendorID', N'INDEX';
GO
For more information, see sp_rename (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
Design a Performant Data Model in Azure SQL Database with Azure Data Studio - Training
Learn how to create a data model, tables, indexes, constraints, and use data types with Azure data studio.
Certification
Microsoft Certified: Azure Database Administrator Associate - Certifications
Administer an SQL Server database infrastructure for cloud, on-premises and hybrid relational databases using the Microsoft PaaS relational database offerings.