Last active
September 25, 2025 23:08
-
-
Save daltonjorge/1b9ee926d90943b8823df83db348838c to your computer and use it in GitHub Desktop.
Close existing connections to a SQL Server database #sqlserver #sql #database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- disconnect all other sessions connected to the database 'syscit' | |
| USE master; | |
| GO | |
| ALTER DATABASE syscit SET SINGLE_USER WITH ROLLBACK IMMEDIATE; | |
| GO | |
| -- drop the database 'syscit' if it exists | |
| IF EXISTS (SELECT name FROM sys.databases WHERE name = N'syscit') | |
| BEGIN | |
| DROP DATABASE syscit; | |
| END | |
| GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment