SA0167 : Non-ISO standard comparison operator found |
The topic describes the SA0167 analysis rule.
Non-ISO standard comparison operator found
It is advisable to use ISO standard comparison operators instead of non-ISO standard operators to help ensure optimal cross-platform and future version compatibility.
While it is currently acceptable to use such non-ISO operators, you should consider that statements that you create might not be supported on other ISO-compliant database management systems.
Also, non-ISO standard comparison operators may not be supported on future versions of SQL Server.
Replace the Non-ISO comparison operators with ISO standard operators.
* Not equal to: Use <> instead of !=
* Greater than or equal to: Use >= instead of !<
* Less than or equal to: Use <= instead of !>
The rule has a Batch scope and is applied only on the SQL script.
Rule has no parameters.
The rule does not need Analysis Context or SQL Connection.
Design Rules, Code Smells
There is no additional info for this rule.
SQL
1-- Test Case 1: The violation should be reported 2SELECT Column1 FROM Table1 WHERE Column1 != 1 3-- Test Case 2: The violation should be reported 4SELECT Column1 FROM Table1 WHERE Column1 !< 1 5-- Test Case 3: The violation should be reported 6SELECT Column1 FROM Table1 WHERE Column1 !> 1 7 8-- Test Case 4: A violation should not be reported 9SELECT Column1 FROM Table1 WHERE Column1 <> 1 10-- Test Case 5: A violation should not be reported 11SELECT Column1 FROM Table1 WHERE Column1 >= 1 12-- Test Case 6: A violation should no be reported 13SELECT Column1 FROM Table1 WHERE Column1 <= 1 |
SQL
1-- Test Case 1: The violation should be reported 2SELECT Column1 FROM Table1 WHERE Column1 <> 1 3-- Test Case 2: The violation should be reported 4SELECT Column1 FROM Table1 WHERE Column1 >= 1 5-- Test Case 3: The violation should be reported 6SELECT Column1 FROM Table1 WHERE Column1 <= 1 7 8-- Test Case 4: A violation should not be reported 9SELECT Column1 FROM Table1 WHERE Column1 <> 1 10-- Test Case 5: A violation should not be reported 11SELECT Column1 FROM Table1 WHERE Column1 >= 1 12-- Test Case 6: A violation should no be reported 13SELECT Column1 FROM Table1 WHERE Column1 <= 1 |
Message | Line | Column | |
---|---|---|---|
1 | SA0167 : Non-ISO standard comparison operator found: != | 2 | 41 |
2 | SA0167 : Non-ISO standard comparison operator found: !< | 4 | 41 |
3 | SA0167 : Non-ISO standard comparison operator found: !> | 6 | 41 |