prav
prav

Reputation: 450

EXEC sp_who2 - LastBatch?

I have got a CPU usage problem. To find the information on processing queries, I used:

EXEC sp_who2 

I have got the results, in the result set one of the column lastBatch. Could any one explain what is LastBatch and how it could be useful for analysis of expensive queries?

Upvotes: 5

Views: 14648

Answers (1)

RThomas
RThomas

Reputation: 10880

lastBatch is simply the date/time of the last batch executed by the connection identified in the sp_who2 record. It's primary usage is pretty straight-forward... it tells you when the connection last executed a batch.

As for how it could be used in analysis of expensive queries related specifically to your CPU problem... It could help you match up the date/time of the batch executed by the connection with a perfmon session. Knowing the date/time would allow you to see exactly what kind of load the cpu was under at the time the batch ran. (As long as you were actively tracing perfmon in order to have something you could refer back to.)

The sp_who2 also returns other useful information like cmd that you can analyze deeper with a variety of dmv's etc.

Upvotes: 5

Related Questions