In this post, I am providing different scripts to rename Database, Table, and Column of SQL Server.
In day to day life, renaming Database or other objects is common requirements for all database professional.
But as much as, we should avoid this practice because stored procedures or functions are using table or column on which you are going to execute rename operation.
During rename operation, You will also get below warning message.
Caution: Changing any part of an object name could break scripts and stored procedures.
You can use SP_RENAME to rename different objects.
Script to Rename Databases:
EXEC SP_RENAMEDB 'Old_Database', 'New_Database'
Script to Rename Tables:
EXEC SP_RENAME 'Old_Table','New_Table'
Script to Rename Columns:
@ObjName = 'Table_Name.Old_Column'
,@NewName = 'New_Column'
,@ObjType = 'COLUMN'
Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.
If you like this post, then please share it with others.
Please follow dbrnd.com, I will share my experience towards the success of Database Research and Development Activity.
I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.