Permalink
Browse files

[Dashboard] Add GetLocks column query

  • Loading branch information...
gboge committed Jul 6, 2017
1 parent 5ca59f8 commit 3104b966df074dd346ccbbbc615632ce2928e901
Showing with 25 additions and 0 deletions.
  1. +25 −0 KServer.cs
View
@@ -1161,6 +1161,31 @@ public static DataTable DashboardIsAlive(this smo.Server s)
return d.ExecuteWithResults("select 1").Tables[0];
}
public static DataTable DashboardGetLocks(this smo.Server s, int durationInMinute, List<string> queriesToIgnore)
{
StringBuilder filter = new StringBuilder();
foreach (string query in queriesToIgnore)
{
filter.AppendLine(" AND st.text NOT LIKE '" + query + "'");
}
smo.Database d = s.Databases["master"];
string sql = string.Format(@"SELECT TOP 20 qe.session_id
, qe.blocking_session_id
, qe.start_time
, CASE WHEN LEN(st.text) < 100 THEN st.text ELSE SUBSTRING(st.text, 0, 100) + ' (...)' END AS query
FROM sys.dm_exec_requests qe (nolock)
INNER JOIN sys.dm_exec_sessions s (nolock) ON qe.session_id = s.session_id
CROSS APPLY sys.dm_exec_sql_text(qe.sql_handle) st
WHERE (DATEDIFF(SECOND, qe.start_time, GETDATE())) / {0} > 0
AND s.is_user_process = 1
AND st.text NOT LIKE 'sp_server_diagnostics%'
{1}
ORDER BY qe.start_time", durationInMinute, filter.ToString());
return d.ExecuteWithResults(sql).Tables[0];
}
public static bool IsOleAutomationProcedureActivated(this smo.Server s)
{
foreach (Microsoft.SqlServer.Management.Smo.ConfigProperty c in s.Configuration.Properties)

0 comments on commit 3104b96

Please sign in to comment.