Reputation: 239
How to change column name to a new name.
eg: Column name is "Sr.No." I want to change it to "ID"
i used
sp_RENAME 'Matrix.Sr.No.','ID','COLUMN';
but it gives me error.
Msg 15253, Level 11, State 1, Procedure sp_rename, Line 105
Syntax error parsing SQL identifier 'Matrix.Sr.No.'.
Upvotes: 2
Views: 13738
Reputation: 2562
Try this
EXEC sp_rename
@objname = 'table_name.old_column_name',
@newname = 'new_column_name',
@objtype = 'COLUMN'
Upvotes: 3
Reputation: 238048
Matrix.Sr.No
means the No
column in the Sr
table of the Matrix
schema in the current database. Try escaping the name:
sp_RENAME 'Matrix.[Sr.No.]','ID','COLUMN';
Upvotes: 4