SA0022 : Index type (CLUSTERED or NONCLUSTERED) not specified

The topic describes the SA0022 analysis rule.

Message

Index type (CLUSTERED or NONCLUSTERED) not specified

Description

This rule checks that creation of indexes is done with explicit specification of index type.

It is recommended that the CLUSTERED or NONCLUSTERED specifications be used (as appropriate) when creating an index.

Scope

The rule has a Batch scope and is applied only on the SQL script.

Parameters

Rule has no parameters.

Remarks

The rule does not need Analysis Context or SQL Connection.

Categories

Design Rules, Code Smells

Additional Information

There is no additional info for this rule.

Example Test Script
SQL
 1CREATE NONCLUSTERED INDEX IX_SalesPerson_SalesQuota_SalesYTD
 2    ON Sales.SalesPerson (SalesQuota, SalesYTD);
 3
 4-- NONCLUSTERED or CLUSTERED type should be specified
 5CREATE INDEX IX_ProductVendor_VendorID 
 6    ON Purchasing.ProductVendor (VendorID); 
 7
 8-- NONCLUSTERED or CLUSTERED type should be specified
 9CREATE UNIQUE INDEX AK_UnitMeasure_Name 
10    ON Production.UnitMeasure(Name);
11
12-- NONCLUSTERED or CLUSTERED type should be specified
13CREATE UNIQUE INDEX AK_Index ON #Test (C2)
14    WITH (IGNORE_DUP_KEY = ON);

Analysis Results

  Message Line Column
1 SA0022 : Index type (CLUSTERED or NONCLUSTERED) not specified. 5 7
2 SA0022 : Index type (CLUSTERED or NONCLUSTERED) not specified. 9 14
3 SA0022 : Index type (CLUSTERED or NONCLUSTERED) not specified. 13 14
See Also

Other Resources