Skip to content

Instantly share code, notes, and snippets.

@vansha
Last active December 16, 2015 16:49
Show Gist options
  • Save vansha/5466002 to your computer and use it in GitHub Desktop.
Save vansha/5466002 to your computer and use it in GitHub Desktop.
Quickly Remove all connections to database (to be able to restore it). (tanks to @denisreznik)
ALTER DATABASE <dbname> SET OFFLINE WITH ROLLBACK IMMEDIATE
GO
ALTER DATABASE <dbname> SET MULTI_USER
GO
ALTER DATABASE <dbname> SET ONLINE
GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment