Differences
This shows you the differences between two versions of the page.
control_sql_-_sql_server_processes [2019/01/27 11:29] |
control_sql_-_sql_server_processes [2019/01/27 11:29] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== | ||
+ | |||
+ | |||
+ | |||
+ | ===== Explanation of SQL ===== | ||
+ | |||
+ | |||
+ | |||
+ | This query will show a list of the SQL Processes. | ||
+ | |||
+ | |||
+ | |||
+ | If you need to filter the list by a specific database, you can remove the comment from the where clause. | ||
+ | |||
+ | |||
+ | |||
+ | Note: As of Version 04.60.1203.2901, | ||
+ | |||
+ | |||
+ | |||
+ | ===== Risk of Data Corruption if Run Improperly ===== | ||
+ | |||
+ | **None**. This is a selection query and no data is modified in the running of it. | ||
+ | |||
+ | |||
+ | |||
+ | ===== SQL ===== | ||
+ | |||
+ | |||
+ | |||
+ | <code sql> | ||
+ | USE Master; | ||
+ | SELECT P.blocked Is_Blocked, P.spid Process_ID, D.name Database_Name, | ||
+ | | ||
+ | P.cmd Command, S.text QueryText, P.login_time Login_Time, P.last_batch Last_Batch_Time, | ||
+ | | ||
+ | | ||
+ | P.cpu Cumulative_CPU_Time , P.physical_io Cumulative_Disk_IO, | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | FROM sys.sysprocesses P | ||
+ | LEFT JOIN sys.databases D ON (D.database_id = P.dbid) | ||
+ | CROSS APPLY sys.dm_exec_sql_text(sql_handle) S | ||
+ | |||
+ | --where D.Name = ' | ||
+ | ORDER BY P.blocked DESC, D.name, P.program_name, | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | ===== Version Information ===== | ||
+ | * Entered : 10/21/2011 | ||
+ | * Version : | ||
+ | |||
+ | |||
+ | |||