Modify database name with single user mode

Modify database name with single user mode

USE MASTER;
GO
ALTER DATABASE AdventureWorks2012
SET SINGLE_USER WITH
ROLLBACK IMMEDIATE;
GO
ALTER DATABASE AdventureWorks2012 MODIFY NAME = AdventureWorks
GO
ALTER DATABASE AdventureWorks
SET MULTI_USER;
GO