Wait Stats capture script

Performance troubleshooting should begin with capturing wait stats so we can understand where SQL Server is busy. The script below captures wait stats into a table in tempdb; the script should be ran via a SQL Server Agent job or some other scheduling mechanism.

The dbo.WaitDefs table contains a listing of all documented wait stats – for comprehensive information regarding specific wait types, check Paul Randal’s wait-types library.