| title | Rename Tables (Database Engine) | Microsoft Docs | ||||
|---|---|---|---|---|---|
| ms.custom | |||||
| ms.date | 06/13/2017 | ||||
| ms.prod | sql-server-2014 | ||||
| ms.reviewer | |||||
| ms.technology | table-view-index | ||||
| ms.topic | conceptual | ||||
| helpviewer_keywords |
|
||||
| ms.assetid | 2f5c922d-4d71-4694-9fca-28dd99375799 | ||||
| author | stevestein | ||||
| ms.author | sstein | ||||
| manager | craigg |
You can rename a table in [!INCLUDEssCurrent] by using [!INCLUDEssManStudioFull] or [!INCLUDEtsql].
Caution
Think carefully before you rename a table. If existing queries, views, user-defined functions, stored procedures, or programs refer to that table, the name modification will make these objects invalid.
In This Topic
-
Before you begin:
-
To rename a table, using:
Renaming a table will not automatically rename references to that table. You must manually modify any objects that reference the renamed table. For example, if you rename a table and that table is referenced in a trigger, you must modify the trigger to reflect the new table name. Use sys.sql_expression_dependencies to list dependencies on the table before renaming it.
Requires ALTER permission on the table.
-
In Object Explorer, right-click the table you want to rename and choose Design from the shortcut menu.
-
From the View menu, choose Properties.
-
In the field for the Name value in the Properties window, type a new name for the table.
-
To cancel this action, press the ESC key before leaving this field.
-
From the File menu choose Savetable name.
-
In Object Explorer, connect to an instance of [!INCLUDEssDE].
-
On the Standard bar, click New Query.
-
The following example renames the
SalesTerritorytable toSalesTerrin theSalesschema. Copy and paste the following example into the query window and click Execute.USE AdventureWorks2012; GO EXEC sp_rename 'Sales.SalesTerritory', 'SalesTerr';
For additional examples, see sp_rename (Transact-SQL).