0
- T-SQL Renaming SQL Server database objects and changing object owners
- Rename a database with
sp_renamedb
orsp_rename
- Rename a database with
Example: rename database from Test1 to Test2
ALTER DATABASE [Test1] MODIFY NAME = [Test2]
--or
sp_renamedb 'Test1' , 'Test2
--or
sp_rename 'Test1', 'Test2', 'DATABASE';
- This could be any object that exists with SQL Server table, stored procedure, trigger, etc.
Example: rename object Test1 to Test2.
sp_rename 'dbo.Test1', 'Test2', 'OBJECT';