Ten minutes ago I created a scratch db instance with a name I mistyped. Not good!
Fortunately, I have admin privileges so I can change it in my lab environment. If you're an admin AND no other users are accessing the DB instance, here's what you can do:
USE master
go
EXEC sp_renamedb 'MetroWrongName', 'MetroRightName'
GO
If someone is using the instance, there is a workaround. Do this:
USE master
go
-- flag the instance for single user only
EXEC sp_dboption 'MetroWrongName','Single User', True
GO
-- make the name change with the rename sproc
EXEC sp_renamedb 'MetroWrongName', 'MetroRightName'
GO
-- flag the newly named instance back to mulitusers
EXEC sp_dboption 'MetroRightName','Single User', False
GO