Situatie
Pentru cazurile in care vrem sa stim ce anume executa un user pe server, am creat o procedura care primeste ca parametru un login si, pentru acel login, arata ce se executa in acel moment pe serverul de sql sau ultima executie a acelui login, dintr-o sesiune activa de pe server.
Solutie
— exec ExecutionPerUser ‘BOGDAND\bogda’
alter procedure ExecutionPerUser
@login varchar(max)
as
SELECT
c.session_id,
s.host_name,
s.login_name,
s.status,
st.text,
s.login_time,
s.program_name
FROM sys.dm_exec_connections c
INNER JOIN sys.dm_exec_sessions s ON c.session_id = s.session_id
CROSS APPLY sys.dm_exec_sql_text(most_recent_sql_handle) AS st
where login_name = @login
ORDER BY c.session_id
Leave A Comment?