Skip to content

Instantly share code, notes, and snippets.

@jetstreamin
Created August 23, 2019 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jetstreamin/96ae46632fe37ec8ce9f7839345d00a1 to your computer and use it in GitHub Desktop.
Save jetstreamin/96ae46632fe37ec8ce9f7839345d00a1 to your computer and use it in GitHub Desktop.
SQL Kill All Connections
USE [master];
DECLARE @kill varchar(8000) = '';
SELECT @kill = @kill + 'kill ' + CONVERT(varchar(5), session_id) + ';'
FROM sys.dm_exec_sessions
WHERE database_id = db_id('LSST')
SELECT @kill
EXEC(@kill);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment