Rename columns (Database Engine)
Applies to:
SQL Server 2016 (13.x) and later
Azure SQL Database
Azure SQL Managed Instance
You can rename a table column in SQL Server by using SQL Server Management Studio or Transact-SQL.
Before you begin
Limitations and restrictions
Renaming a column won't 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.
Permissions
Requires ALTER permission on the object.
Using SQL Server Management Studio
Rename a column using Object Explorer
- In Object Explorer, connect to an instance of Database Engine.
- In Object Explorer, right-click the table in which you want to rename columns and choose Rename.
- Type a new column name.
Rename a column using Table Designer
- 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, select Save table 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.
Using Transact-SQL
Rename a column
The following example renames the column ErrorTime in the table dbo.ErrorLog to ErrorDateTime in the AdventureWorksLT database.
EXEC sp_rename 'dbo.ErrorLog.ErrorTime', 'ErrorDateTime', 'COLUMN';
Note the output warning, and verify other objects or queries have not been broken:
Caution: Changing any part of an object name could break scripts and stored procedures.
For more information, see sp_rename (Transact-SQL).
Next steps
Povratne informacije
Pošalјite i prikažite povratne informacije za