Skip to content

Instantly share code, notes, and snippets.

@akramarev
Created March 16, 2018 21:25
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 akramarev/e4630ab43484e49abd9e6aec54d60bea to your computer and use it in GitHub Desktop.
Save akramarev/e4630ab43484e49abd9e6aec54d60bea to your computer and use it in GitHub Desktop.
DECLARE @kill varchar(8000) = '';
SELECT @kill = @kill + 'kill ' + CONVERT(varchar(5), session_id) + ';'
FROM sys.dm_exec_sessions
WHERE
database_id = db_id('DBUser')
AND login_name IN ('DBTest', 'DBServices')
EXEC(@kill);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment