| title | Rename Columns (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 | 7c71ec9f-0180-4398-b32a-4bfb7592e75d | |||
| author | stevestein | |||
| ms.author | sstein | |||
| manager | craigg |
You can rename a table column in [!INCLUDEssCurrent] by using [!INCLUDEssManStudioFull] or [!INCLUDEtsql].
In This Topic
-
Before you begin:
-
To rename columns, using:
Renaming a column will not automatically rename references to that column. You must modify any objects that reference the renamed column manually. For example, if you rename a table column and that column is referenced in a trigger, you must modify the trigger to reflect the new column name. Use sys.sql_expression_dependencies to list dependencies on the object before renaming it.
Requires ALTER permission on the object.
-
In Object Explorer, connect to an instance of [!INCLUDEssDE].
-
In Object Explorer, right-click the table in which you want to rename columns and choose Rename.
-
Type a new column name.
-
In Object Explorer, right-click the table to which you want to rename columns and choose Design.
-
Under Column Name, select the name you want to change and type a new one.
-
On the File menu, click Savetable name.
Note
You can also change the name of a column in the Column Properties tab. Select the column whose name you want to change and type a new value for Name.
To rename a column
-
In Object Explorer, connect to an instance of [!INCLUDEssDE].
-
On the Standard bar, click New Query.
-
The following example renames the column
TerritoryIDin the tableSales.SalesTerritorytoTerrID. Copy and paste the following example into the query window and click Execute.USE AdventureWorks2012; GO EXEC sp_rename 'Sales.SalesTerritory.TerritoryID', 'TerrID', 'COLUMN'; GO
For more information, see sp_rename (Transact-SQL).