Using begin_sample and end_sample

With the begin_sample and end_sample parameters, you can invoke sp_sysmon to start sampling, issue queries, and end the sample and print the results at any point in time. For example:

sp_sysmon begin_sample
execute proc1
execute proc2
select sum(total_sales) from titles
sp_sysmon end_sample

NoteOn systems with many CPUs and high activity, counters can overflow if the sample period is too long.

If you see negative results in your sp_sysmon output, reduce your sample time.