SQL Server 2005/2008/2008R2/2012 Performance Statistics collection scripts

The attached batch file, TSQL Scripts plus sqldiag configuration file (XML) can be used together with sqldiag.exe (shipped as part of SQL Server 2005/2008/2008R2/2012/2014 installation) to collect data for SQL Nexus to analyze. It can collect profiler trace, blocking and DMV output.

Where to download?

The batch files used to collect data is now part of the main download. Once unzipped, you will see "data collectors".

How to Use it?

Unzip to a local disk on a SQL 2005, 2008 or 2008 R2 machine and run SartSQLDiagTrace.cmd, SartSQLDiagTrace2008.cmd, SartSQLDiagTrace2008R2.cmd or any other batch file depending on what what you need. See Next Section on what to collect.

What will each batch file collect?

  1. All the batch files will collect these:
    • Performance scripts by SQL2005PerfStats.sql or SQL2008PerfStats.sql. it will capture DMVs and blocking information to help troubleshoot performance problems blocking, high CPU etc.
    • Profiler trace (each batch file will capture different events and StartSQLDiagNoTrace.cmd doesn't capture any trace)
    • Perfmon
    • msinfo32
    • Windows event logs (system, security and application logs)
  2. Different batch files capture profiler trace events differently. Everything else mentioned in the above section will be captured exactly the same.
    • StartSQLDiagTrace.cmd, StartSQLDiagTrace2008.cmd and StartSQLDiagTrace20082.cmd: they capture general profiler trace events. This is the most commonly used and is sufficient to do initial troubleshoot performance problems.
    • StartSQLDiagDetailed_Trace.cmd, StartSQLDiagTrace2008.cmd and StartSQLDiagTrace2008R2.cmd: They capture detailed profiler trace events. This has slightly higher overhead than general profiler trace events. But it is useful if you want to identify statement level events. For example, you have identified a stored procedure consuming high CPU. not you want to focus on individual statements within that stored procedure.
    • StartSQLDiagForReplay.cmd, StartSQLDiagForReplay2008.cmd and StartSQLDiagForReplay2008R2.cmd: They will capture profiler trace events needed for readtrace to do replay. Replay is used if you want to simulate production workload in your test system.
    • StartSQLDiagNoTrace.cmd: This one won't capture profiler trace. Since it's not used that often 2008 doesn't have one.

How to customize it?