Command Line Tool - AnalyzeServer
Introduction
Section titled “Introduction”Analyze T-SQL script files and SQL Server stored procedures, functions and triggers.
Target SQL Server objects.
Enlight analyzeServer --objectName=<objectName> --objectType==<objectType> --connectionString=<connectionString> | --server=<servername> --database=<databasename> [ --user=<username> --password=<password> ] [ --includeRules=<rules> ] [ --excludeRules=<rules> ] [ --reportOutput=<reportPath>] [ --reportStyleSheet=<stylesheet>] [ --contextFile=<contextfilePath>]
[ --templateFile=<analysisTemplateFile>] [ --maxAge=<maxAge>] [ --settings=<settingsFile>] [ --properties=propertyName=value;propertyName;value] [ --whitelistFile=<whitelist file>] [ --qualityGate=<qualityGatePath>] [ --failOn=QualityGateFail|QualityGateFailOrWarn|AnyIssue] [ --exitCodeOnViolations= <exitCode>]Parameters
Section titled “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:
[dbo].[mysp_MyStoredProcedure]Example of analyzing all objects of a particular schema:
/[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 to 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. Can be path to XSLT stylesheet, or one of the known stylesheet names: HTML, JSON, JUNIT, CSV or VSTESTS |
| 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” or “[d.]hh: mm[:ss]”. |
| settings | A settings file which to override the current user’s settings XML file. |
| qualityGate | Optional path to quality gate definition JSON or XML. |
| failOn | (Default: AnyIssue) Optional flag to exit with error code when the Quality Gate fails. Valid values: QualityGateFail, QualityGateFailOrWarn, AnyIssue |
Build Machines edition specific parameters:
| Parameters | Description |
|---|---|
| licenseData | Required. License data or activation response file path. |
| exitCodeOnViolations | The argument can be used to return custom exit code in case when there are analysis rule violations. The exit code can be used in CI to fail or flag the build as unstable. |
| reportPerTarget | Create own report file for each analyzed file or SQL module. |
| demoMode | Run analysis in a demo mode with limited results. |
Examples
Section titled “Examples”Analyze all stored procedures in MyDatabase using the analysis rules selected in the current analysis template and create HTML report.
Enlight analyzeServer --database=sqldb01 --includeRules=design,performance,sa001,sa030,sa033 --objectName=* --objectType=StoredProcedure --reportOutput="f:\analysis reports\sqldb01-analysis-report1.html" --reportStylesheet="C:Program Files\Yubitsoft\SQL Enlight\Xslt\SqlEnlightReport.xslt" --server=sqlsrvtest est1Analyze Azure SQL Database, use custom analysis template, explicitly specify rules and rule parameters and generate report XML.
Enlight analyzeServer --connectionString="Server=tcp:mysrv.db.windows.net,1433;Authentication=Active Directory Password;Database=myDb;UID=user@domain;PWD=myPass;" --database=myDb --includeRules=ex0018,performance --objectName=* --objectType=Database --reportOutput="f:\analysis reports\myDb-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:.
Enlight analyzeServer --server=. --database=MyDatabase --includeRules=ex0018,performance --objectName=/[MySchema].[.*]/ --objectType=Database --reportOutput="f:\analysis reports\MyDatabase-analysis-report1.html" --reportStylesheet=HTMLAnalyze all database objects, which are modified in less than 1 day and 6 hours, use specific analysis rules and create standalone HTML report
Enlight analyzeServer --server=.\sql2019 --database=AdventureWorks --includeRules=ex0018,performance --maxAge=1.06:00 --objectName=AdventureWorks --objectType=Database --reportOutput="f:\analysis reports\MyDatabase-analysis-report1.html" --templateFile="d:\sql enlight\my-custom-analysis-template.xml"