Click or drag to resize

SA0233 : Non-ANSI not equal operator used (!=)

The topic describes the SA0233 analysis rule.

Message

Non-ANSI not equal operator used (!=)

Description

The rule checks for usage of the Non-ANSI not equal operator '!='.

It is recommended to use the ANSI operator not equal operator <>.

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, New Rules

Additional Information

There is no additional info for this rule.

Example Test Script
SQL
 1CREATE INDEX IX_Table1_value ON Table1 (value)
 2
 3ALTER TABLE Table1 ADD computed_value AS (CASE WHEN value = 'value1' then 1 ELSE 0 END)
 4
 5CREATE INDEX IX_Table1_computed_value ON Table1(computed_value)
 6
 7-- Not equal operator used in the WHERE clause.
 8SELECT * 
 9FROM  Table1 t1
10WHERE t1.value <> 'value1' and t1.value != 'value2';
11
12-- Equal operator used in the WHERE clause.
13SELECT * 
14FROM Table1 t1
15WHERE t1.computed_value = 0
16if (1 != 2)  select 1
17
18while 1 != 2
19select 2

Analysis Results

 MessageLineColumn
1SA0233 : Non-ANSI not equal operator used (!=).1040
2SA0233 : Non-ANSI not equal operator used (!=).166
3SA0233 : Non-ANSI not equal operator used (!=).188
See Also

Other Resources