Groups Category
Operators Category
Identifiers Category
Clauses Category
Constants Category
Comments Category
Variables Category
Keywords Category
Punctuation Category
Unknown Category
Predefined Category
System Category
SQL Enlight uses a XML-based language to describe T-SQL statements called SQML which stands for Structured Query Markup Language.
T-SQL batch as SQML:
<g:batch>
<g:statements>
<pu:semicolon>
<g:statement>
...
</g:statement>
</pu:semicolon>
</g:statemetns>
</g:batch>
NOTE
Since version 1.7.0.494,the SQML elements: pu:optional, pu:essential and pu:bindingare no longer generated and are replaced by pu:semicolon and pu:dot.
This change may berak any analysis rules prior to release 1.7.0.494 that use the obsolete SQML elements.
| Old | New |
|---|---|
| pu:binding[@name=';'] | pu:semicolon |
| pu:binding[@name='.'] | pu:dot |
| pu:essential[@name=';'] | pu:semicolon |
| pu:essential[@name='.'] | pu:dot |
| pu:optional[@name=';'] | pu:semicolon |
| pu:optional[@name='.'] | pu:dot |
Custom analysis rules can be fixCustom analysis rules can be fixed to use the new elements, manually or automatically from the Settings-> Analysis Settings->Fix analysis rules using obsolete SQML elements option.
SQML elements are separated in different categories which have specific namespaces.
<g:batch>
<g:statements>
...
<g:statement>
...
</g:statement>
...
</g:statemetns>
</g:batch>
Namespace for all container elements.The namespace prefix is "g:".
Element | Description |
|---|---|
| batch | SQML root element. |
| statements | Element containing multiple statement elements. This element mostly appears as a child of the batch element. |
| statement | Container for T-SQL statement. |
| brackets | The expression inside parentheses is written as child of this element. |
| expression | Appears as parent element of arithmetic expressions. |
| boolean-expression | Appears as parent element of logical expressions. |
| commalist | The content of this element is a list of elements which in the T-SQL statement appear as a comma separated list. |
Operators
All arithmetic and bitwise operatros are scoped in this namespace. The namespace prefix is "o:". SQML uses prefix notation (Polish notation) to descried arithmetic and logical expressions. The operator is the parent element and operands are written as child elements. The first child represents the left operand and the second child represents the right operand in the expression.
Element | Description |
|---|---|
| additive | + - |
| multiplicative | * / % |
| assignment | += -= *= /= %= &= ^= |= |
| bitwise | ~ ^ & | |
| comparison | < > != = <> <= >= !< !> |
| shift | << >> |
| unary | - + |
| old-outter-join | Old style outer join operators : *= and =*. |
The elements form this group have these attributes:
Attribute | Description |
|---|---|
| name | Operator name is written in this attribute. It is stored in lowercase. |
T-SQL arithmetic expression:
a + b + 1
SQML:
<g:expression>
<o:additive name="+">
<o:additive name="+">
<i:common name="a"/>
<i:common name="b"/>
</o:additive>
<co:exact-number>1</co:exact-number>
</o:additive>
</g:expression>
T-SQL logical expression:
a>1 and b = 3
SQML:
<g:boolean-expression> <k:and> <o:comparison name=">"> <g:expression> <i:common name="a"/> </g:expression> <g:expression> <co:exact-number>1</co:exact-number> </g:expression> </o:comparison> <o:comparison name="="> <g:expression> <i:common name="b"/> </g:expression> <g:expression> <co:exact-number>3</co:exact-number> </g:expression> </o:comparison> </k:and> </g:boolean-expression>
Identifiers
There are four kinds of identifiers delimited, quoted, labels common. The Namespace prefix is "i:".
Element | Description |
|---|---|
| delimited | Delimited identifier. |
| quoted | Quoted identifier. |
| labels | Label name. |
| common | Common non-delimited identifier. |
Multipart identifiers are represented using prefix notation as the parent element is the pu:binding[@name="."].The child elements are the left and the right identifier elements.
The elements form this group have these attributes:
Attribute | Description |
|---|---|
| name | Identifier name is in written in this attribute. |
T-SQL multipart identifier:
server_name.[database_name].[schema_name].object_name
SQML:
<pu:dot> <i:common name="server_name"/> <u:dot> <i:delimited name="database_name"/> <u:dot> <i:delimited name="schema_name"/> <i:common name="object_name"/> </u:dot> </u:dot> </u:dot>
Clauses
All T-SQL clauses are in this category. The namespace prefix is "c:". The names of the elements which belong to this category are the names of actual T-SQL clauses. The names are in lowercase.
All constant values are in this category. The values of elements from this namespace are written in as element content. The namespace prefix for is "co:".
Element | Description |
|---|---|
| string | Literal string. |
| exact-number | Integer number. |
| float-number | Floating point number. |
| hex | Hexadecimal number. |
| money | Currency number. |
| bool | Boolean value (true, false). |
| extended-sql ( extended SQL is handled as a constant string ) | Extended SQL expression is written as a literal string expression and is contained in this element. |
TSQL:
3 'literal string'
SQML:
<co:exact-number>3</co:exact-number> <co:string>'literal string'</co:string>
Comments
The comments in the T-SQL script are in this category. The comments are stored in as content of the element. The namespace prefix for this category is "cmt:".
Element | Description |
|---|---|
| singleline | Single line comment. |
| multiline | Block comment. |
Comment elements are attached to the last token before the comment itself.
T-SQL:
SELECT column1, column2 FROM table1 /* test comment */
SQML:
<k:select> <g:commalist> ... </g:commalist> <k:from> <g:commalist> <i:common name="table1"> <cmt:multiline>/* test comment */</cmt:multiline> </i:common> </g:commalist> </k:from> </k:select>
Variables
This is a category for the T-SQL variables. Variable name is written in the name attribute. The namespace prefix for this category is 'v:'.
Element | Description |
|---|---|
| local | Local variables ( @variable ). |
| global | Global variables ( @@variable ). |
| server | Server functions ( @@SERVERNAME, @@CONNECTIONS, @@VERSION, @@LOCK_TIMEOUT and etc. ). |
The elements form this group have these attributes:
Attribute | Description |
|---|---|
| name | Variable name is in written in this attribute. |
Keywords
All T-SQL reserved keywords are in this category. The namespace prefix is "k:". The names of the elements which belong to this category are the names of actual T-SQL reserved keywords. The names are in lowercase.
The namespace prefix for this category is "pu:".
Element | Description |
|---|---|
| simple | Common punctuation element. Element is now obsolete and is not used. |
| binding | Binding punctuation ( like '.' in the multipart identifier names). Element is now obsolete and is not used. |
| optional | Optional punctuation ( like ';' ). Element is now obsolete and is not used. |
| semicolon | Replaces pu:essential[@name=';'] and pu:optional[@name=';'] elements. |
| dot | Replaces pu:binding[@name='.'] element. |
The elements form this group have these attributes:
Attribute | Description |
|---|---|
| name | Attribute is now obsolete and is not used. |
Example SQML:
<g:batch> <g:statements> <pu:semicolon> <g:statement> ... </g:statement> </pu:semicolon> </g:statements> </g:batch>
Unknown
This category holds the T-SQL syntax elements which not fall in any of the other categories. We are working on removing such elements, but there are a few left. The namespace prefix for this category is "u:". The only element which belongs here is the 'unknown' element.
Element | Description |
|---|---|
| unknown | The only element in this category. |
The elements form this group have these attributes:
Attribute | Description |
|---|---|
| value | The value of the not categorized token is in written in this attribute. |
This category includes well known T-SQL object names (such as data types, set options, hints and etc.) which have specific scope and usage in the T-SQL grammar. The namespace prefix for this category is "pr:".
Element | Description |
|---|---|
| datatype | SQL data types. |
| aggregate | T-SQL aggregate functions (COUNT,AVG,SUM and etc.). |
| function | The possible values are CAST and COLUMNS_UPDATED. |
| sizeunit | Size units. The possible values are KB,MB,GB and TB. |
| dbcc-option | DBCC statement options. |
| backup-option | Backup statement options. |
| bulk-option | Bulk statement options. |
| setting-option | SET statement options. |
| hint | Table hints and query hints.
Possible values: READCOMMITTEDREPEATABLEREAD READUNCOMMITTED FASTFIRSTROW PAGLOCK ROWLOCK SERIALIZABLE TABLOCK TABLOCKX UPDLOCK NOLOCK READPAST CONCAT FAST FORCE HASH KEEP LOOP MAXDOP MERGE XLOCK ROBUST REMOTE NOEXPAND KEEPDEFAULTS IGNORE_CONSTRAINTS IGNORE_TRIGGERS READCOMMITTEDLOCK OPTIMIZE KEEPFIXED EXPAND VIEWS MAXRECURSION QUERYTRACEON Note: The hints which reserved keywords fall in the Keywords category. |
| built-in-function | The function names of system table functions invoked as in SQL Sever 2000 without the "::" prefix. |
| collation-name | Collation name. |
| column-ref | The reference to specific system column or function. Possible values: $ROWGUID$IDENTITY $PARTITION $ACTION |
| event-notification | Event names and event group names. |
The elements form this group have these attributes:
Attribute | Description |
|---|---|
| name | The attribute holds the name of the predefined element. |
System
SQL Enlight adds some specific attributes which to be later used by the analysis engine. The attributes specify the position of the tokens and optionally their type.
Attribute | Description |
|---|---|
| sline | Start line number. |
| eline | End line number. |
| scol | Start column. |
| ecol | End column. |
| type | Token type. This attribute is optional and currently is used only to specify if the given element is inserted by the engine or not.
Possible values: "opt" - specifies that the element is optional and can be omitted "opt+" - the element is optional and was explicitly added. |
The namespace prefix is "se:".
Example SQML:
<g:batch se:sline="1" se:scol="0" se:eline="2" se:ecol="30">
<g:statements>
<pu:semicolon se:sline="1" se:scol="0" se:eline="1" se:ecol="1" se:type="opt+">
<g:statement se:sline="1" se:scol="0" se:eline="2" se:ecol="30">
...
</g:statement>
</pu:semicolon>
</g:statements>
</g:batch>

