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.