Using begin_sample and end_sample

When you use begin_sample and end_sample, you can invoke sp_sysmon to start and end the sample, issue queries, and print results at any point in time. For example, to start and end the sample for the RepAgent group of counters, enter:

sp_sysmon begin_sample
go
execute proc1
go
sp_sysmon end_sample,repagent