Skip to content

Latest commit

 

History

History
100 lines (91 loc) · 11.2 KB

table_of_contents.md

File metadata and controls

100 lines (91 loc) · 11.2 KB

Table of Contents

Design

Rule Id Friendly Name Ignorable Description Example?
SRD0001 Missing natural key Table does not have a natural key.
SRD0002 Missing primary key Table does not have a primary key.
SRD0003 Avoid wide primary keys Primary Keys should avoid using GUIDS or wide VARCHAR columns.
SRD0004 Index on Foreign Key Columns on both sides of a foreign key should be indexed.
SRD0005 Avoid long CHAR types Yes Avoid the (n)char column type except for short static length data.
SRD0006 Avoid SELECT * Yes Avoid using SELECT *.
SRD0009 Non-transactional body Wrap multiple action statements within a transaction.
SRD0010 Low identity seed value Start identity column used in a primary key with a seed of 1000 or higher.
SRD0011 Equality Compare With NULL Rule Equality and inequality comparisons involving a NULL constant found. Use IS NULL or IS NOT NULL.
SRD0012 Unused variable Variable declared but never referenced or assigned.
SRD0013 Expected error handeling Wrap multiple action statements within a try catch.
SRD0014 TOP without an ORDER BY TOP clause used in a query without an ORDER BY clause.
SRD0015 Implicit column list Always use a column list in INSERT statements.
SRD0016 Unused input parameter Yes Input parameter never used. Consider removing the parameter or using it.
SRD0017 Avoid Deletes Without Where Rule Yes DELETE statement without row limiting conditions.
SRD0018 Unbounded UPDATE Yes UPDATE statement without row limiting conditions.
SRD0019 Avoid joining tables with views Yes Avoid joining tables with views.
SRD0020 Incomplete or missing JOIN predicate The query has issues with the join clause. It is either missing a backing foreign key or the join is missing one or more columns.
SRD0021 Consider EXISTS Instead Of In Rule Yes Consider using EXISTS instead of IN when used with a subquery.
SRD0024 Avoid EXEC or EXECUTE Yes Avoid EXEC and EXECUTE with string literals. Use parameterized sp_executesql instead.
SRD0025 Avoid ORDER BY with numbers Yes Avoid using column numbers in ORDER BY clause.
SRD0026 Unspecified type length Do not use these data types (VARCHAR, NVARCHAR, CHAR, NCHAR) without specifying length.
SRD0027 Unspecified precision or scale Do not use DECIMAL or NUMERIC data types without specifying precision and scale.
SRD0028 Consider Column Prefix Rule Yes Consider prefixing column names with table name or table alias.
SRD0030 Avoid Use of HINTS Yes Avoid using Hints to force a particular behavior.
SRD0031 Avoid using CHARINDEX Yes Avoid using CHARINDEX function in WHERE clauses.
SRD0032 Avoid use of OR in where clause Yes Try to avoid the OR operator in query where clauses if possible. (Sargable)
SRD0033 Avoid Cursors Yes Avoid using cursors.
SRD0034 Use of NOLOCK Do not use the NOLOCK clause.
SRD0035 Forced delay Do not use WAITFOR DELAY/TIME statement in stored procedures, functions, and triggers.
SRD0036 Do not use SET ROWCOUNT Yes Do not use SET ROWCOUNT to restrict the number of rows.
SRD0038 Alias Tables Rule Yes Consider aliasing all table sources in the query.
SRD0039 Object not schema qualified Use fully qualified object names in SELECT, UPDATE, DELETE, MERGE and EXECUTE statements. [schema].[name].
SRD0041 Avoid SELECT INTO temp or table variables Yes Avoid use of the SELECT INTO syntax.
SRD0043 Possible side-effects implicit cast The arguments of the function '{0}' are not of the same datatype.
SRD0044 Error handling requires SA permissions The RAISERROR statement with severity above 18 requires the WITH LOG clause.
SRD0045 Excessive indexes on table Excessive number of indexes on table found on table.
SRD0046 Use of approximate data type Do not use the real or float data types for parameters or columns as they are approximate value data types.
SRD0047 Ambiguous column name across design Yes Avoid using columns that match other columns by name, but are different in type or size.
SRD0050 Expression reducible to constaint Yes The comparison expression always evaluates to TRUE or FALSE. Yes
SRD0051 Do Not Use Deprecated Types Rule Don?t use deprecated TEXT, NTEXT and IMAGE data types.
SRD0052 Duplicate/Overlapping Index Index has exact duplicate or borderline overlapping index.
SRD0053 Explicit collation other Yes Object has different collation than the rest of the database. Try to avoid using a different collation unless by design.
SRD0055 Object level option override The object was created with invalid options.
SRD0056 Unsafe identity retrieval Yes Use OUTPUT or SCOPE_IDENTITY() instead of @@IDENTITY.
SRD0057 Do Not Mix DML With DDL Rule Do not mix DML with DDL statements. Group DDL statements at the beginning of procedures followed by DML statements.
SRD0058 Ordinal parameters used Always use parameter names when calling stored procedures.
SRD0060 Permission change in stored procedure The procedure grants itself permissions. Possible missing GO command. Yes
SRD0061 Invalid database configured options The database is configured with invalid options.
SRD0062 Implicit collation Create SQL Server temporary tables with the correct collation or use database default as the tempdb having a different collation than the database can cause issues and or data instability.
SRD0063 Avoid wrapping SQL in IF statement Yes Do not use IF statements containing queries in stored procedures.
SRD0064 Consider Caching Get Date To Variable Yes Cache multiple calls to GETDATE or SYSDATETIME into a variable.
SRD0065 Avoid NOT FOR REPLICATION Avoid 'NOT FOR REPLICATION' unless this is the desired behavior and replication is in use.

Performance

Rule Id Friendly Name Ignorable Description Example?
SRP0001 Nested Views Views should not use other views as a data source.
SRP0002 Unanchored string pattern Yes Try to avoid using patterns that start with '%' when using the LIKE keyword if possible. (Sargable)
SRP0003 Aggregate of unique set Yes Avoid using DISTINCT keyword inside of aggregate functions.
SRP0004 Noisy trigger Yes Avoid returning results in triggers.
SRP0005 Noisy trigger Yes SET NOCOUNT ON is recommended to be enabled in stored procedures and triggers.
SRP0006 Use of inequality Yes Try to avoid using not equal operator (<>,!=) in the WHERE clause if possible. (Sargable)
SRP0007 Dangling cursor Local cursor not closed.
SRP0008 Unfreed cursor Local cursor not explicitly deallocated.
SRP0009 Filtering on calculated value Yes Avoid wrapping columns within a function in the WHERE clause. (Sargable)
SRP0010 Function in data modification Yes Avoid the use of user defined functions with UPDATE/INSERT/DELETE statements. (Halloween Protection)
SRP0011 Non-member test in predicate Yes Avoid using the NOT IN predicate in a WHERE clause. (Sargable)
SRP0012 Un-indexed membership test Yes Consider indexing the columns referenced by IN predicates in order to avoid table scans.
SRP0013 Existence tested with JOIN Yes Consider replacing the OUTER JOIN with EXISTS. Yes
SRP0014 Table variable in JOIN Yes Avoid the use of table variables in join clauses.
SRP0015 Avoid Column Calculations Yes Avoid the use of calculations on columns in the where clause. (Sargable)
SRP0016 Equality test with mismatched types Data types on both sides of an equality check should be the same in the where clause. (Sargable)
SRP0017 Update of Primary key Yes Avoid updating columns that are part of the primary key. (Halloween Protection)
SRP0018 High join count Query uses a high number of joins.
SRP0020 Missing Clustered index Table does not have a clustered index.
SRP0021 Manipulated parameter value Yes Avoid modification of parameters in a stored procedure prior to use in a select query.
SRP0022 Procedure level recompile option Yes Consider using RECOMPILE query hint instead of the WITH RECOMPILE option. Yes
SRP0023 Enumerating for existence check Yes When checking for existence use EXISTS instead of COUNT
SRP0024 Correlated subquery Yes Avoid the use of correlated subqueries except for very small tables.

Naming

Rule Id Friendly Name Ignorable Description Example?
SRN0001 UDF with System prefix Yes Avoid 'fn_' prefix when naming functions.
SRN0002 Procedure name may conflict system name Yes Avoid 'sp_' prefix when naming stored procedures.
SRN0006 Use of default schema Two part naming on objects is required.
SRN0007 Name standard General naming rules.