Msg 15225,Level 11,State 1,Procedure sp_rename,Line 338
USE [master]; GO ALTER DATABASE foo SET SINGLE_USER WITH ROLLBACK IMMEDIATE; GO --EXEC sys.sp_renamedb @dbname = N'foo',@newname = N'bar'; ALTER DATABASE foo MODIFY NAME = bar; -- preferred way GO ALTER DATABASE bar SET MULTI_USER;