Situatie
Mai jos este o procedura ce listeaza toate queri-urile active ce folosesc o anumita tablea, care este primita de procedura drept parametru pe un server MSSQL.
Solutie
alter PROCEDURE FindActiveQueriesThatUseTableX_prc
@table varchar(max)
as
SELECT sqltext.TEXT,
req.session_id,
req.status,
req.command,
req.cpu_time,req.database_id,
req.total_elapsed_time
FROM sys.dm_exec_requests req
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS sqltext where CHARINDEX(@table, sqltext.text) > 1
Leave A Comment?