Home
LIKE clauses should not be used without wildcards
Rule description
- LIKE clauses should not be used without wildcards
Non-compliant Code Example
SELECT p.FirstName, p.LastName, ph.PhoneNumber FROM Person.PersonPhone AS ph INNER JOIN Person.Person AS p ON ph.BusinessEntityID = p.BusinessEntityID WHERE ph.PhoneNumber LIKE '4154856178' --Non compliant code (Like clause is used without wild cards) ORDER by p.LastName;
Compliant Code Example
SELECT p.FirstName, p.LastName, ph.PhoneNumber FROM Person.PersonPhone AS ph INNER JOIN Person.Person AS p ON ph.BusinessEntityID = p.BusinessEntityID WHERE ph.PhoneNumber LIKE '415%' --Compliant code (Like clause is used with wild cards) ORDER by p.LastName;