SQL Nexus is a tool that helps you identify the root cause of SQL Server performance issues. It loads and analyzes performance data collected by SQLDiag and PSSDiag. It can dramatically reduce the amount of time you spend manually analyzing data. One of the least commonly known facts is that the SQL Nexus tool also allows you to run it’s reports using command line arguments or even import diagnostic data automatically. The command line help reference is shown below. You can find more details on GitHub.
sqlnexus.exe [ [ /S [ /E | /Uuser /Ppwd ] [/D"database"] ] | [/C"connstr"] ] [/Iinputpath] [/Ooutputpath] [/Rreport] [/X] sqlnexus.exe [ [ /S [ /E | /Uuser /Ppwd ] [/D"database"] ] | [/C"connstr"] ] [/Iinputpath] [/Ooutputpath] [/Rreport] [/X] [/Q] [/N] /S"server" Specifies a SQL Server name to connect to. /D"database" Database to connect to /E Log in to SQL using Windows/integrated security /Uuser Specifies a SQL (non-Windows) login name /Ppassword Specifies the password for a SQL (non-Windows) login /C"connstring" Specifies the SqlClient ConnectionString to use (can be used instead of /S /E). /I"path" Import SQL diagnostic data from this path /R"report" Specifies a report file name to run. /O"path" Specifies an export path for reports executed via /R. Also this is where the sqlnexus.000.log would get created /X Exit after importing (/I) or exporting (/O) the specified report (/R) /Vparam=value Specify the value of a form parameter /Q Quiet Mode - minimize windows in console mode /N Create a new SQLNexus database before importing (drop existing).
Automating Report Execution
The first scenario that I want to outline is the need to automate a report execution especially when you need to execute the reports repeatedly after activities like performance testing or during some other iterative activity which requires analysis of various sets of diagnostic data.
This can be achieved using the command line parameters shown below:
sqlnexus.exe /S"." /X /D"sqlnexus" /R"\Summary.rdl" /O""
As you can see from the screenshot below, you can see that I have a standard report i.e. “Bottleneck Analysis_C.xls” that was exported and a non-standard report which I created Summary.xls in the same folder. This also gives additional opportunity to create your own performance reports and schedule them using the SQL Nexus executable.
After you have the exported reports, you could also write additional automation to email the reports as required.
Automating Data Import
SQL Nexus also allows you to perform data imports automatically using the command line parameters. The command line shown below performs data import from the specified folder into a SQL Server database called sqlnexustest on the default SQL server instance installed on the machine.
sqlnexus.exe /S"." /X /D"sqlnexustest" /I"C:\temp\output"
If the database does not exist on the SQL Server instance, then it will be created. The settings for SQL Nexus utility will be used during the data import which were saved when the last time the UI was used. So if you have disabled the profiler trace import from the UI and saved your settings, then the command line execution will not import the profiler traces.