Click or drag to resize
Command Line Tool - Analyze

Analyze T-SQL script files and SQL Server stored procedures, functions and triggers.

This topic contains the following sections:

Usage

Target SQL Server objects.

 1enlight.exe   analyze 
 2             /targettype:serverobjects | /tt:serverobjects
 3           [ /server:<servername> ]
 4           [ /database:<databasename> ]
 5           [ /user:<username>  /password:<password> ]
 6             /objecttype:<objecttype>
 7             /objectname: <objectname> | /objectname:"/<objectname_regex>/"
 8           [ /rules:<rules> ]
 9           [ /report:<reportpath> | /rs:<reportpath> ]
10           [ /parametersfile:<parametersfile> ]
11           [ /template:<analysistemplatefile> |/t:<analysistemplatefile>]
12           [ /reportstylesheet:<stylesheetpath> | /rs:<stylesheetpath> ]
13           [ /maxage: <maxage>]
14           [ /settings: <settingsfile>]
15           [ /verbosity: <verbosity> | /v: <verbosity> ]

Target T-SQL script files.

 1enlight.exe   analyze 
 2             /targettype:files | /tt:files
 3             /inputpath:<paths> | /i:<paths>
 4           [ /rules:<rules> ]
 5           [ /parametersfile:<parametersfile> ]
 6           [ /report:<reportpath> | /r:<reportpath> ]
 7           [ /reportstylesheet:<stylesheetpath> | /rs:<stylesheetpath> ]
 8           [ /contextfile:<contextfilepath> |/cf:<contextfilepath>]
 9           [ /server:<servername> /database:<databasename> [ /user:<username>  /password:<password> ] ]
10           [ /template:<analysistemplatefile> |/t:<analysistemplatefile>]
11           [ /maxage: <maxage>]
12           [ /verbosity: <verbosity> | /v: <verbosity> ]
13           [ /settings: <settingsfile>]
14           [ /recursive]
Parameters

Parameters

Description

/targettype

The allowed values are:

  • serverobjects - for analyzing server and database objects

  • files - for analyzing T-SQL script files

/server:<servername>

Target SQL Server name. Optional.

/database:<databasename>

Target database name. Can be omitted if Server or ServerTrigger object types are used. Default database is "master".

/user:<username>

Username for accessing the database. Optional. If omitted integrated security will be used.

/password:<password>

User password for accessing the database. Optional. If omitted integrated security will be used.

/objecttype:<objecttype>

Type of the objects that will be analyzed.

The allowed object types are:

TypeDescription
ServerIncludes server triggers and all functions,views, procedures and triggers in the server databases.
ServerTriggerIncludes server triggers.
ViewIncludes all views in specific database.
DatabaseIncludes all functions, views, procedures and triggers in specific database.
DmlTriggerIncludes all DML triggers.
DatabaseTriggerIncludes all DDL triggers.
UserDefinedFunctionIncludes all user defined functions.
DatabaseProgrammabilityObject Includes functions , database triggers and stored procedures.
StoredProcedure Includes all stored procedures.

/objectname:<objectname> or /objectname:"/<object_name_regex>/"

This parameter specifies the name of the target objects and supports one of three options:

  • When the value of the parameter is set to '*' or not provided, all objects of the type specified by ObjectType will be matched.

  • For match exact object, the single-part delimited name for server triggers or two-part delimited name for database functions, views and stored procedures: [server_trigger_name] or [schema_name].[object_name]

  • When the value is enclosed in forward slashes, it is threated as regular expression literal and is matched against the fully qualified object name.

Examples:

For analyzing a exact database object: [dbo].[mysp_MyStoredProcedure]

For analyzing all objects of a particular schema: /\[schema_name\]\.\[.*\]/

/rules:<rules>

';' or ',' separated list of rule names or analysis group names. If omitted the current SQL Enlight settings will be used.

/parametersfile:<parametersfile>

Path to a XML file containing the values for the analysis rules parameters.

Check Schemas\AnalysisParameters.xsd for the parameters file XML schema.

/report:<reportpath> or /r:<reportpath>

Target output file for the analysis report.

/reportstylesheet:<stylesheetpath> or /rs:<stylesheetpath>

XSLT document that to be used to transform the report XML.

/inputpath:<paths> or /i:<paths>

Location of the T-SQL script files. A list of files separated with semicolon can also be provided. The '-' prefix can be used to exclude specific files.

/contextfile:<contextfilepath> or /cf:<contextfilepath>

Path to an analysis context file which to be used for analyzing the target script files.

An analysis context file can be generated using the AnalysisContext command.

/template:<analysistemplatefile> |/t:<analysistemplatefile>

Optional parameter for setting external analysis template. The external template will be used as a source for the analysis rules instead of the default template.

See Analysis Template Import/Export topic for information how to save existing template in a file.

/recursive

Optional. Include files in subfolders.

/maxage: <maxage>

Optional. MAXimum file or database object AGE - exclude objects older than given date or time interval. When date is provided, can be any valid culture specific date time string(e.g. "2/16/2015 12:15:12 PM"). If age is provided in time interval, the valid format is "d | [d.]hh:mm[:ss]".

/verbosity:<verbosity> or /v:<verbosity>

Output verbosity level. Supported values: quiet, normal and detail.

/settings: <settingsfile>

A settings file which to override the current user's settings XML file.

Can be used to override some of the options which are not available as parameters for the command line tool, MSBuild and NAnt tasks, but are configurable using SQL Enlight user interface.

See Settings XML File for more details.

Examples

Analyze all stored procedures in MyDatabase using the analysis rules selected in the current analysis template and create HTML report.

1enlight.exe  analyze
2            /tt:serverobjects 
3            /database:MyDatabase 
4            /objecttype:storedprocedure 
5            /objectname:* 
6            /rules:sa001,sa030,sa033
7            /r:"C:\MyAnalysisReports\MyDatabaseReport.html"
8            /rs: "C:\Program Files\Ubitsoft\SQL Enlight\Xslt\SqlEnlightReport.xslt"

Analyze all objects in MyDatabase that match the specified regular expression, using the all active rules in the current analysis template and create HTML report.

1enlight.exe  analyze
2            /tt:serverobjects 
3            /database:MyDatabase 
4            /objecttype:Database 
5            /objectname:"/\[MySchema\]\.\[.*\]/" 
6            /r:"C:\MyAnalysisReports\MyDatabaseReport.html"
7            /rs: "C:\Program Files\Ubitsoft\SQL Enlight\Xslt\SqlEnlightReport.xslt"

Analyze all database objects, which are modified in less than 1 day and 6 hours, use specific analysis rules and create XML report.

 1enlight.exe  analyze
 2            /targettype:serverobjects
 3            /server:.
 4            /database:AdventureWorks
 5            /objecttype:database
 6            /objectname:AdventureWorks
 7            /rules:ex0018,Design,Performance
 8            /template: "C:\Program Files\Ubitsoft\SQL Enlight\Templates\Analysis\DefaultTemplate.xml"
 9            /parametersfile: "C:\Program Files\Ubitsoft\SQL Enlight\Xml\AnalysisParameters.xml"
10            /report: "E:\Projects\MyProject\Build\Reports\AdventureWorks_Database_AnalysisReport.xml"
11            /maxage:1.06:00

Analyze target T-SQL script files using specific analysis rules and create HTML report using provided stylesheet.

1enlight.exe  analyze
2            /targettype:files
3            /inputpath:"E:\Projects\MyProject\SQL Script\AdventureWorks.sql"
4            /rules:ex0018,Design,Performance
5            /template: "C:\Program Files\Ubitsoft\SQL Enlight\Templates\Analysis\DefaultTemplate.xml"
6            /parametersfile: "C:\Program Files\Ubitsoft\SQL Enlight\Xml\AnalysisParameters.xml"
7            /context: "E:\Projects\MyProject\Build\Context\AdventureWorks.xml"
8            /report: "E:\Projects\MyProject\Build\Reports\AdventureWorks_Script_AnalysisReport.xml"
9            /reportstylesheet: "C:\Program Files\Ubitsoft\SQL Enlight\Xslt\SqlEnlightReport.xslt"

Analyze the all *.sql files except the B*.sql files and create HTML report using provided stylesheet.

1enlight.exe  analyze
2            /targettype:files
3            /inputpath:"E:\Projects\MyProject\SQL Script\*.sql";-"E:\Projects\MyProject\SQL Script\B*.sql"
4            /report: "E:\Projects\MyProject\Build\Reports\Scripts_AnalysisReport.html"
5            /reportstylesheet: "C:\Program Files\Ubitsoft\SQL Enlight\Xslt\SqlEnlightReport.xslt"

Analyze the all *.sql with a context loaded using a database connection.

1enlight.exe  analyze
2            /targettype:files
3            /inputpath:"E:\Projects\MyProject\SQL Script\*.sql";-"E:\Projects\MyProject\SQL Script\B*.sql"
4            /server:.
5            /database:AdventureWorks
6            /report: "E:\Projects\MyProject\Build\Reports\Scripts_AnalysisReport.html"
7            /reportstylesheet: "C:\Program Files\Ubitsoft\SQL Enlight\Xslt\SqlEnlightReport.xslt"
See Also