Description:
Change the name of a user created object (table, column, etc.) in the current database.
Syntax:
sp_rename
[
@objname =] 'object_name',
[
@newname =] 'new_name'
[, [
@objtype =] 'object_type']
@objname |
Original object name (in case of the column, the table name must be included). |
@newname |
New object name. |
@objtype |
Type of the renamed object ('COLUMN', 'DATABASE', 'INDEX', 'OBJECT' or 'USERDATATYPE'). |
Example:
Change the name of the column from time to when in the table data.
EXEC sp_rename 'data.time', 'when', 'COLUMN'