December 14, 2009 at 6:54 am
Trying to assemble a 'KILL User' process which will explicitly kill those processes for User = 'MyDomain\MyUser'. the following T-SQL will identify all tranlocks for all users on a DB.
How can I limit the list of request_session_id to the domain user name: 'MyDomain\MyUser' ?
declare @databasename varchar(100)
set @databasename = 'MyUserDB'
select request_session_id from sys.dm_tran_locks
where resource_type='DATABASE'
AND DB_NAME(resource_database_id) = @databasename
December 14, 2009 at 7:52 am
You need to join to sys.dm_exec_sessions like this:
SELECT
*
FROM
sys.dm_tran_locks AS DTL JOIN
sys.dm_exec_sessions AS DES
ON DTL.request_session_id = DES.session_id
WHERE
DES.login_name = 'MyDomain\MyUser'
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply