Click or drag to resize
Analysis Context

The Analysis Context represents the current server and database schema information that SQL Enlight loads before starting the analysis.

This topic contains the following sections:

The analysis context is a XML document which holds information for the current SQL Server, the current database.

The current database is determined initially from the SQL connection and later by the database switches ( USE [DatabaseName] statements) inside the script.

XML Schema

Analysis Context XML Schema is included in SQL Enlight installation: \Schemas\AnalysisContext.xsd

Query the Analysis Context

Example XPath expression for retrieving the XML node of the function ufnGetAccountingStartDate from database AdventureWorks:

XSLT
1<xsl:variable name="function" select="$context/Server/Databases/Database[@Name='AdventureWorks']/Functions/Function[@Name='ufnGetAccountingStartDate']"/>

Or

XSLT
1<xsl:variable name="function" select="$server/Databases/Database[@Name='AdventureWorks']/Functions/Function[@Name='ufnGetAccountingStartDate']"/>

The same XPath expression, but assuming that the 'AdventureWorks' database is the current database:

XSLT
1<xsl:variable name="function" select="$database/Functions/Function[@Name='ufnGetAccountingStartDate']"/>
Generating Analysis Context XML

Sometimes it can be handy to be able to test your analysis rules with different than the default test analysis context.

You can create your own analysis context XML for testing your analysis rules either by editing the AdventureWorks one or by using the Enlight command line tool with command analysiscontext.

See Also