How to rename column name of a table in SQL Server

The system stored procedure “sp_rename” is used for renaming user-created objects in the database.
The following code is renaming the column “empdoj” to “empjoindate” in “emp” table.

sp_rename 'dbo.emp.empdoj', 'empjoindate', 'column'
  • The first parameter is the original object name, in order to rename a column, the corresponding table name must be included in the first parameter.
  • The second parameter is the desired name of the object.
  • The third parameter is an object type and it is optional and the default is NULL.

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: