Home

Column names should be used in an ORDER BY clause

Rule description

  • Column names should be used in an ORDER BY clause

 

Non-compliant Code Example

SELECT ProductID, Name, Color  
FROM Production.Product  
ORDER BY 1;  --Non compliant code (Column name is not used in Order by Clause)

Compliant Code Example

SELECT ProductID, Name, Color, ListPrice  
FROM Production.Product  
ORDER BY ListPrice;  --Compliant code (Column name is used in Order by Clause)
Visual Expert 2020
 VETSQLRULE33