Home
SELECT statements used as argument of EXISTS statements should be selective
Rule description
- SELECT statements used as argument of EXISTS statements should be selective
Non-compliant Code Example
SELECT TypeId, TypeName, TypeCategory FROM Type1 WHERE EXISTS(SELECT TypeId FROM Type2) --Non compliant code (SELECT statements used as argument of EXISTS statements is not selective) GO
Compliant Code Example
SELECT TypeId, TypeName, TypeCategory FROM Type1 WHERE EXISTS(SELECT TypeId FROM Type2 WHERE TYPE2.Id = Type1.Id) --Compliant code (SELECT statements used as argument of EXISTS statements is selective) GO