Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

You can right-click the query you are interested in and select Show execution plan: enter image description here

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: enter image description here

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top