SELECT
spc.Param1,
spc.Param2,
...,
spc.Param99,
COUNT_BIG(*)
FROM dbo.StoredProcedureCall spc
WHERE
spc.StoredProcedureName = 'sp_YourProc'
GROUP BY
spc.Param1,
spc.Param2,
...,
spc.Param99
ORDER BY
COUNT_BIG(*) DESC;
这将给出sp_YourProc被调用的不同参数,从最常见到最不常见排序。
如果您不关心这些值,而只想知道正在使用某些参数组合,则可以像这样替换静态值:
SELECT
CASE WHEN spc.Param1 <> '' THEN 1 ELSE 0 END,
CASE WHEN spc.Param2 <> '' THEN 1 ELSE 0 END,
...,
CASE WHEN spc.Param99 <> '' THEN 1 ELSE 0 END,
COUNT_BIG(*)
FROM dbo.StoredProcedureCall spc
WHERE
spc.StoredProcedureName = 'sp_YourProc'
GROUP BY
CASE WHEN spc.Param1 <> '' THEN 1 ELSE 0 END,
CASE WHEN spc.Param2 <> '' THEN 1 ELSE 0 END,
...,
CASE WHEN spc.Param99 <> '' THEN 1 ELSE 0 END,
ORDER BY
COUNT_BIG(*) DESC;
您需要找到给定过程的所有不同参数值组,然后按这些组的计数进行排序。像这样的东西:
这将给出
sp_YourProc
被调用的不同参数,从最常见到最不常见排序。如果您不关心这些值,而只想知道正在使用某些参数组合,则可以像这样替换静态值: