Sp_renamedb - TSQL Tutorial

On Transact SQL language the sp_renamedb is part of Database Engine Stored Procedures and changes the name of a database.

Sp_renamedb syntax:

sp_renamedb [ @dbname = 'Old database name' ] , [ @newname = 'New database name' ] ;


Rename a database name:

USE master;
GO
CREATE DATABASE myTest;
GO
EXEC sp_renamedb N'myTest', N'Test';
GO

Messages
The database name 'Test' has been set.