Export (0) Print
Expand All

Rename Indexes

This topic describes how to rename an index in SQL Server 2014 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

Limitations and Restrictions

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.

Security

Permissions

Requires ALTER permission on the index.

Arrow icon used with Back to Top link [Top]

To rename an index by using the Table Designer

  1. In Object Explorer, click the plus sign to expand the database that contains the table on which you want to rename an index.

  2. Click the plus sign to expand the Tables folder.

  3. Right-click the table on which you want to rename an index and select Design.

  4. On the Table Designer menu, click Indexes/Keys.

  5. Select the index you want to rename in the Selected Primary/Unique Key or Index text box.

  6. In the grid, click Name and type a new name into the text box.

  7. Click Close.

  8. On the File menu, click Save table_name.

To rename an index by using Object Explorer

  1. In Object Explorer, click the plus sign to expand the database that contains the table on which you want to rename an index.

  2. Click the plus sign to expand the Tables folder.

  3. Click the plus sign to expand the table on which you want to rename an index.

  4. Click the plus sign to expand the Indexes folder.

  5. Right-click the index you want to rename and select Rename.

  6. Type the index’s new name and press Enter.

Arrow icon used with Back to Top link [Top]

To rename an index

  1. In Object Explorer, connect to an instance of Database Engine.

  2. On the Standard bar, click New Query.

  3. Copy and paste the following example into the query window and click Execute.

    USE AdventureWorks2012;
    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).

Arrow icon used with Back to Top link [Top]

Community Additions

ADD
Show:
© 2014 Microsoft