SQL – Rename ( Objects )

Spread the love

SQL – Rename – through systems stored procedure object’s name can be changed

SQL – RENAME A TABLE

EXEC sp_rename ‘DATABASE_NAME.TABLE_NAME‘, ‘NEW_TABLE_NAME‘;

 

SQL – RENAME A DATABASE

EXEC sp_renamedb N’EXISTING_NAME’, N’NEW_NAME’;

SQL – RENAME A COLUMN_NAME

EXEC sp_rename ‘SchemaName.TableName.EXISTING_COLUMN_NAME‘, ‘NEW_COLUMN_NAME’, ‘COLUMN‘;

 

RENAME A VIEW

EXEC sp_rename ‘dbo.VIEW_NAME‘, ‘NEW_VIEW_NAME

 

RENAME A STORED PROCEDURE

There is not an option to rename a stored procedure , need to drop and recreate the stored procedure