Command Line Tool – AnalyzeServer

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 analyzeServer
 2      --connectionString=<connectionString> 
 3    | --server=<servername> --database=<databasename> [ --user=<username>  --password=<password> ]
 4    [ --includeRules=<rules> ]
 5    [ --excludeRules=<rules> ]
 6    [ --reportOutput=<reportPath>]
 7    [ --reportStylesheet=<stylesheetpath>]
 8    [ --contextFile=<contextfilePath>]
 9
10    [ --templateFile=<analysisTemplateFile>]
11    [ --maxAge=<maxAge>]
12    [ --settings=<settingsFile>]
13    [ --properties=propertyName=value;propertyName;value]
14    [ --whitelistFile=<whitelist file>]
15    [ --exitCodeOnViolations= <exitCode>]

Parameters

Parameters

Description

–objectName

Required. 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.

Example of analyzing an exact database object:

1[dbo].[mysp_MyStoredProcedure]

Example of analyzing all objects of a particular schema:

1/[schema_name].[.*]/

–objectType

Required. (Default: Database) Type of the objects that will be analyzed. Valid values: Server, ServerTrigger, View, Database, DmlTrigger, DatabaseTrigger, UserDefinedFunction, DatabaseProgrammabilityObject, StoredProcedure

–nologo

Do not show header and copyright info.

–verbosity

Output verbosity level. Valid values: Normal, Quiet, Detail

–connectionString

SQL connection string the target context database.

–username

Username for accessing the database.

–password

SQL connection string.

–database

Target database name.

–server

Target SQL Server name and instance name.

–contextFile

Optional analysis context file.

–reportOutput

Output file for the generated report.

–reportStylesheet

Xml Stylesheet, which to be used for styling the report.

–templateFile

Analysis template with rules file, which to be used instead of the standard set of rules.

–properties

Custom properties, which to be provided to the generated report.

–includeRules

A comma separated list of rules, which to be enabled during the analysis.

–excludeRules

A comma separated list of rules, which to be disabled during the analysis.

–whitelistFile

Optional whitelist file containing entries of objects that to be removed form the analysis results.

–maxAge

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]”.

–settings

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

Build Machines edition specific parameters:

Parameters

Description

–licenseKey

Required. License key.

–licenseData

Required. License data or activation response file path.

Examples

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

1Enlight analyzeServer
2        --database=sqldb01
3        --includeRules=design,performance,sa001,sa030,sa033
4        --objectName=*
5        --objectType=StoredProcedure 
6        --reportOutput="f:analysis reportssqldb01-analysis-report1.html"
7        --reportStylesheet="C:Program FilesYubitsoftSQL EnlightXsltSqlEnlightReport.xslt"
8        --server=sqlsrvtest        est1

Analyze Azure SQL Database, use custom analysis template, explicitly specify rules and rule parameters and generate report XML.

1Enlight analyzeServer
2        --connectionString="Server=tcp:mysrv.db.windows.net,1433;Authentication=Active Directory Password;Database=myDb;UID=user@domain;PWD=myPass;"
3        --database=myDb
4        --includeRules=ex0018,performance
5        --objectName=* --objectType=Database
6        --reportOutput="f:analysis reportsmyDb-analysis-report1.html"

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 analyzeServer
2        --server=.
3        --database=MyDatabase 
4        --includeRules=ex0018,performance
5        --objectName=/[MySchema].[.*]/
6        --objectType=Database
7        --reportOutput="f:analysis reportsMyDatabase-analysis-report1.html"
8        --reportStylesheet="C:Program FilesYubitsoftSQL EnlightXsltSqlEnlightReport.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 analyzeServer
 2        --server=.sql2019
 3        --database=AdventureWorks
 4        --includeRules=ex0018,performance
 5        --maxAge=1.06:00
 6        --objectName=AdventureWorks
 7        --objectType=Database
 8        --reportOutput="f:analysis reportsMyDatabase-analysis-report1.html"
 9        --reportStylesheet="C:Program FilesYubitsoftSQL EnlightXsltSqlEnlightReport.xslt"
10        --templateFile="d:sql enlightmy-custom-analysis-template.xml"

See Also

Other Resources