just use this command in query window
USE master; 
GO
DECLARE @sql nvarchar(MAX);
SELECT @sql = ' KILL ' + CAST(session_id as varchar(5))
    FROM sys.dm_exec_sessions
    WHERE database_id = DB_ID(N'[DataFeed_BLM]');
SET @sql = @sql + N' ALTER DATABASE [YourDB] SET MULTI_USER;';
EXEC sp_executesql @sql;
GO
it will shows the process IDs, kill the process id using this command
kill (process id) my process id is 64
like
kill 64
Option 2 : 
This command is helpful too
SELECT request_session_id FROM sys.dm_tran_locks WHERE resource_database_id = DB_ID('YourDB')
Option 3 :
You can also use this command to check the current connection
 use master
GO
select 
d.name, 
d.dbid, 
spid, 
login_time, 
nt_domain, 
nt_username, 
loginame
from sysprocesses p 
inner join sysdatabases d 
    on p.dbid = d.dbid
where d.name = 'YourDB'
GO
 
 
 
 
0 comments:
Post a Comment