To rename a table:
EXEC sp_rename @objname='{TableName}', @newname='{NewTableName}', @objtype='TABLE'
To rename a column:
EXEC sp_rename @objname='{TableName}.{ColumnName}', @newname='{NewColumnName}', @objtype='COLUMN'
Note: you may refrain from specifying the Stored Procedure's parameters (@objname, @newname, @objtype) if you will specify the input in the proper order as specified above. Thus:
To rename a table:
EXEC sp_rename '{TableName}', '{NewTableName}', 'TABLE'
To rename a column:
EXEC sp_rename '{TableName}.{ColumnName}', '{NewColumnName}', 'COLUMN'
1 comment:
I had an error using the object type 'TABLE'. Instead, I used 'OBJECT' and everything went fine.
Post a Comment