Skip to content

Instantly share code, notes, and snippets.

@brandedoutcast
Created November 6, 2015 12:46
Show Gist options
  • Save brandedoutcast/69823a6a1ff66db26b2a to your computer and use it in GitHub Desktop.
Save brandedoutcast/69823a6a1ff66db26b2a to your computer and use it in GitHub Desktop.
Rename a database by setting it into single user mode
USE master
ALTER DATABASE [DatabaseName] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
ALTER DATABASE [DatabaseName] MODIFY NAME = [NewDatabaseName]
ALTER DATABASE [NewDatabaseName] SET MULTI_USER
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment