T-SQL Tutorial

RENAME Column


To rename a column in SQL Server, you can use the sp_rename stored procedure.
The procedure takes two arguments: the name of the existing column and the new name for the column. Please note that renaming a column will also update all references to that column in triggers, views, stored procedures, and functions.

RENAME Column syntax

The syntax to rename a column from a table in the SQL Server database is as follows:


EXEC sp_rename 'Table.Old_Column', 'New_Column', 'COLUMN'


RENAME Column example


Employee table:

Column nameData_type
idint
namevarchar(250)
dep_idint
addressvarchar(400)

EXEC sp_rename 'employee.address', 'new_address', 'COLUMN' ;


This will rename the "address" column in the "employee" table to "new_address".


Result

Column nameData_type
idint
namevarchar(250)
dep_idint
new_addressvarchar(400)