SQL Server Agent jobs collecting useful information, how to save them?

Hi,

I was working on an OLTP environment where tempdb started growing crazy! Before even I got a hold of the server, someone restarted the SQL Service and had a smile on his face (thinking he solved the problem), well, tempdb hadn't learnt it's lesson from this guy :D

I got hold of queries from this link and created a job to understand (one) which spid consumes the space, (two) what's the allocated KB and the de-allocated KB and (three) which query is eating my disk. I scheduled the job to run every 5 minutes (so that I don't miss the allocate and de-allocate pattern) and redirected the output to a text file! (Some of you are laughing at me now, yes, reading a text file for analysis is difficult.

Why not append the output to our SQL Server :-)  

 

Yes, that's simple. Say I have this query which I want to push to a sample table from where I want to analyze; use this technique. (Query window)

 

This will create a table (which you can use to append your data).

In the job, use the below script to append data into that table. (Job Step)

This way, you can have your user table house the data of interest and not worry about how to read it during the analysis.

-KKB

 

 

 

 

Great reference article from Sudarshan (who was my technical lead while I was working at Microsoft): http://thesqldude.com/2012/05/15/monitoring-tempdb-space-usage-and-scripts-for-finding-queries-which-are-using-excessive-tempdb-space/