Analysis Rules
These are all currently available SQL Enlight analysis rules.
The current version of SQL Enlight comes with more than 70 static analysis rules based on best practices and coding guidelines for database development. The rules are grouped in four main categories - Naming, Design, Performance and Explicit Rules.
Naming
Naming issues arise if the name of a database object might cause unexpected problems or violate generally accepted conventions.
| More | Description | |
|---|---|---|
| More | SA0014 : Avoid 'fn_' prefix when naming functions. | |
| More | SA0015 : Avoid 'sp_' prefix when naming stored procedures. | |
| More | SA0042A : Avoid using special characters in object names. (Context Only) | |
| More | SA0042B : Avoid using special characters in object names. (Batch) | |
| More | SA0043A : Avoid using reserved words for type names. (Context Only) | |
| More | SA0043B : Avoid using reserved words for type names. (Batch) | |
| More | SA0061A : Check all Tables in the current database for following specified naming convention.(Context Only) | |
| More | SA0061B : Check table names used in CREATE TABLE statements for table name following specified naming convention.(Batch) | |
| More | SA0062A : Check all Functions in the current database for following specified naming convention.(Context Only) | |
| More | SA0062B : Check function names used in CREATE FUNCTION statements for following specified naming convention. (Batch) | |
| More | SA0063A : Check all Views in the current database for following specified naming convention.(Context Only) | |
| More | SA0063B : Check view names used in CREATE VIEW statements for following specified naming convention. (Batch) | |
| More | SA0064A : Check all Stored Procedures in the current database for following specified naming convention.(Context Only) | |
| More | SA0064B : Check stored procedure names used in CREATE PROCEDURE statements for following specified naming convention. (Batch) | |
| More | SA0065A : Check all Triggers for for following specified naming convention.(Context Only) | |
| More | SA0065B : Check trigger names used in CREATE TRIGGER statements for for following specified naming convention. (Batch) | |
| More | SA0066A : Check all Columns for following specified naming convention.(Context Only) | |
| More | SA0067A : Check all Unique Key Constraints in the current database for following specified naming convention.(Context Only) | |
| More | SA0068A : Check all Check Constraints in the current database for following specified naming convention.(Context Only) | |
| More | SA0069A : Check all Default Constraints in the current database for following specified naming convention.(Context Only) | |
| More | SA0070A : Check all Primary Key Constraints in the current database for following specified naming convention.(Context Only) | |
| More | SA0071A : Check all Foreign Key Constraints in the current database for following specified naming convention.(Context Only) | |
| More | SA0072A : Check all Non-Key Indexes in the current database for following specified naming convention.(Context Only) | |
| More | SA0073A : Check all User-Defined Types in the current database for following specified naming convention.(Context Only) | |
| More | SA0074A : Check all Schemas in the current database for following specified naming convention.(Context Only) | |
| More | SA0075 : Avoid constraints created with system generated name. |
Design
Design issues include code that might not behave the way in which you expect, deprecated syntax, and issues that could cause problems when the design of your database changes.
| More | Description | |
|---|---|---|
| More | SA0001 : Equality and inequality comparisons involving a NULL constant found. Use IS NULL or IS NOT NULL. | |
| More | SA0005 : Non-ANSI outer join syntax. | |
| More | SA0006 : Non-ANSI inner join syntax. | |
| More | SA0008 : Deprecated syntax string = expression_alias. | |
| More | SA0010 : Use TRY..CATCH or check the @@ERROR variable after executing data manipulation statement. | |
| More | SA0011 : SELECT * in stored procedures, views and table-valued functions. | |
| More | SA0012 : Use SCOPE_IDENTITY() instead @@IDENTITY. | |
| More | SA0018 : Support for constants in ORDER BY clause have been deprecated. | |
| More | SA0019 : TOP clause used in a query without an ORDER BY clause. | |
| More | SA0020 : Always use a column list in INSERT statements. | |
| More | SA0021 : Deprecated usage of table hints without WITH keyword. | |
| More | SA0022 : Index type (CLUSTERED or NONCLUSTERED) not specified. | |
| More | SA0031 : Avoid GOTO statement to improve readability. | |
| More | SA0034 : Use parentheses to improve readability and avoid mistakes because of logical operator precedence. | |
| More | SA0035 : TODO,HACK or UNDONE phrase found in a comment. | |
| More | SA0036 : DELETE statement without WHERE clause. | |
| More | SA0037 : UPDATE statement without WHERE clause. | |
| More | SA0038 : The WHERE clause contains comparison which evaluate to TRUE. | |
| More | SA0039 : The WHERE clause contains comparison which evaluate to FALSE. | |
| More | SA0041 : Avoid joining with views. | |
| More | SA0050 : Do not create clustered index on UNIQUEIDENTIFIER columns. | |
| More | SA0051 : Possible result of Cartesian product due to incomplete table joins. | |
| More | SA0052 : Avoid using undocumented and deprecated stored procedures. | |
| More | SA0053A : Don&t use deprecated TEXT,NTEXT and IMAGE data types. ( Context Only) | |
| More | SA0053B : Don&t use deprecated TEXT,NTEXT and IMAGE data types. (Batch) | |
| More | SA0056 : Index has exact duplicate or overlapping index. | |
| More | SA0057 : Consider using EXISTS predicate instead of IN predicate. | |
| More | SA0058 : Avoid converting dates to string during date comparison. | |
| More | SA0059A : Check database for objects created with different than default or specified collation. | |
| More | SA0059B : Check for usage of collation different than the database default or the specified collation. | |
| More | SA0060 : The sp_xml_preparedocument procedure call is not paired with a following sp_xml_removedocument call. | |
| More | SA0076 : Check UPDATE and DELETE statements for not filtering using all the PRIMAR KEY columns of the target table. | |
| More | SA0077 : Avoid executing dynamic code using EXECUTE statement. | |
| More | SA0078 : Statement is not terminated with semicolon. | |
| More | SA0079 : Avoid using column numbers in ORDER BY clause. | |
| More | SA0080 : Do not use VARCHAR or NVARCHAR data types without specifying length. | |
| More | SA0085 : Check database objects for missing specific extended properties. | |
| More | EX0006 : Identify possible missing Foreign Keys. | |
| More | EX0015 : Find Best Clustered Index |
Performance
Performance issues include code database schema configuration that might noticeably reduce the speed in which database operations are completed. Many of these issues identify code that will cause a table scan when the code is executed.
| More | Description | |
|---|---|---|
| More | SA0002 : Variable declared but never used. | |
| More | SA0003 : Variable used but not previously assigned. | |
| More | SA0004 : Variable assigned but value never used. | |
| More | SA0007 : Pattern starting with "%" in LIKE predicate. | |
| More | SA0009 : Consider using a table variable instead temporary table. | |
| More | SA0013 : Avoid returning results in triggers. | |
| More | SA0016 : Use of very small variable length type (size 1 or 2). | |
| More | SA0017 : SET NOCOUNT ON option in stored procedures and triggers. | |
| More | SA0023 : Avoid using not equal operator (<>,!=) in the WHERE clause. | |
| More | SA0024 : Local cursor not closed. | |
| More | SA0025 : Local cursor not explicitly deallocated. | |
| More | SA0026 : Local cursor variable not explicitly deallocated. | |
| More | SA0027 : Avoid wrapping filtering columns within a function in the WHERE clause. | |
| More | SA0028 : Deterministic function calls can be extracted from the WHERE clause to avoid unnecessary table scan. | |
| More | SA0029 : Input parameter never used. | |
| More | SA0030 : Output parameter never assigned. | |
| More | SA0032 : Avoid using NOT IN predicate in the WHERE clause. | |
| More | SA0033 : Do not use the GROUP BY clause without an aggregate function. | |
| More | SA0040 : Consider moving the column reference to one side of the comparison operator in order to use the column index. | |
| More | SA0044 : Consider creating indexes on all columns included in foreign keys. | |
| More | SA0045 : Consider updating statistics as they appear outdated and may mislead the query optimizer. | |
| More | SA0046 : Consider creating statistics on all composite index columns. | |
| More | SA0047 : Consider indexing the column as it is used in a WHERE clause or JOIN condition. | |
| More | SA0048 : Table does not have a primary key. | |
| More | SA0049 : Table does not have a clustered index. | |
| More | SA0054 : Avoid modification of parameters in a stored procedure prior to use in a query. | |
| More | SA0055 : Consider indexing the columns referenced by IN predicates in order to avoid table scans. | |
| More | SA0081 : Do not use DECIMAL or NUMERIC data types without specifying precision and scale. | |
| More | SA0082 : Consider prefixing column names with table name or table alias. | |
| More | SA0077 : Avoid executing dynamic code using EXECUTE statement. | |
| More | EX0010 : Identify missing indexes using dynamic management views information. | |
| More | EX0011 : Identify ineffiecient indexes using dynamic management views information. | |
| More | EX0013 : Identify fragmented indexes that need rebuilding or reindexing. | |
| More | EX0018 : Analyze execution plan and check for high cost operations. |
Maintenance
Maintenance issues include outdated statistics, missing indexes, fragmented indexes and more.
| More | Description | |
|---|---|---|
| More | SA0045 : Consider updating statistics as they appear outdated and may mislead the query optimizer. | |
| More | SA0083 : Consider proactively checking the logical and physical integrity of all the objects in the database. | |
| More | SA0084 : Data purity check is not enabled for the current database. | |
| More | EX0010 : Identify missing indexes using dynamic management views information. | |
| More | EX0011 : Identify ineffiecient indexes using dynamic management views information. | |
| More | EX0013 : Identify fragmented indexes that need rebuilding or reindexing. |
Explicit Rules
Special group of rules for gathering various information that could be useful during general development and code analysis.
| More | Description | |
|---|---|---|
| More | EX0001 : Identify objects used in the script. | |
| More | EX0002 : Get object dependencies - Objects on which database objects depend. | |
| More | EX0003 : Get object dependencies - Objects that depend on other database objects. | |
| More | EX0004 : Find identifier references inside the T-SQL script. | |
| More | EX0005 : Check script for data modifying statements - INSERT,UPDATE,DELETE or EXECUTE. | |
| More | EX0006 : Identify possible missing Foreign Keys. | |
| More | EX0007 : List all DML and DDL triggers in current database. | |
| More | EX0008 : Generate CREATE INDEX statements for all columns included in foreign keys. | |
| More | EX0009 : Consider adding proper comment block before each database object create statement. | |
| More | EX0010 : Identify missing indexes using dynamic management views information. | |
| More | EX0011 : Identify ineffiecient indexes using dynamic management views information. | |
| More | EX0012 : Displays memory usage information for the current database. | |
| More | EX0013 : Identify fragmented indexes that need rebuilding or reindexing. | |
| More | EX0014 : List the last execution status of all available SQL Server jobs. | |
| More | EX0015 : Find Best Clustered Index | |
| More | EX0016 : Generate DROP INDEX statements for inefficient indexes using dynamic management views information. | |
| More | EX0017 : Generate ALTER INDEX statements for rebuilding or reorganizing fragmented indexes. | |
| More | EX0018 : Analyze execution plan and check for high cost operations. |

