SQL Server : kill active connections hold by MASTER database -
i have tried below code kill sql connection other master
database:
declare @kill varchar(8000) = ''; select @kill = @kill + 'kill ' + convert(varchar(5), session_id) + ';' sys.dm_exec_sessions database_id = db_id('mydb') exec(@kill);
this code worked fine me. when have run below query see more active connections found master database has 21 active connection.
select db_name(dbid) dbname, count(dbid) numberofconnections, loginame loginname sys.sysprocesses dbid > 0 group dbid, loginame
while wanted close active connection master database failed , error message was: "cannot use kill kill own process."
please let me know, how can kill 21 active connection master database holding 'sa' account ?
many kind support.
/paul
you can kill active connection database putting database in single user mode, when trying restore on existing inuse database. ....
use master; go alter database [db_name] set single_user rollback immediate; go use [db_name] --<-- grab single available conncection go use master; --<-- no more connections database tadaaaaa... go
Comments
Post a Comment