To view "recent expensive queries" I use Activity Monitor. Some of the queries there are with parameters.
Is there a way to know the values?
Is there a way to know the values?
No, not directly from the Activity Monitor.
You would need to capture those details either using a server-side trace, or using Extended Events.
See the details on this question and the answers for details about how to create a trace to collect that data.
You can right-click the query you are interested in and select Show execution plan
:
Once you have the execution plan open, just right-click in an empty area and select Show Execution Plan XML...
. Once you have that you will see a section in the XML <ParameterList>
. In that node it will show you the ParameterCompiledValue
:
<ParameterList>
<ColumnReference Column="@records" ParameterCompiledValue="(0)" />
<ColumnReference Column="@traceid" ParameterCompiledValue="(2)" />
</ParameterList>
</QueryPlan>
</StmtSimple>
Another way would be to copy the execution plan XML out and paste it into Plan Explorer and view the Parameters
tab:
Edit for the nerds
If you open up Activity Monitor, and then go into tempdb you will find all the temp objects (tables and all) that Activity Monitor is using. For the Expensive Queries it is using the object dbo.#am_get_querystats
. You can open that procedure up and look at the exact query they use to pull it. Pretty cool. I did this for the activity section so I could get similar information without having to open up Activity Monitor all the time.