Click or drag to resize

SA0039 : The comparison expression evaluates to FALSE

The topic describes the SA0039 analysis rule.

Message

The comparison expression evaluates to FALSE

Description

The rule checks for comparison expressions which will always evaluate to FALSE.

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

Additional Information

There is no additional info for this rule.

Example Test Script
 1-- Comparison will always evaluate to FALSE. 
 2-- *****************************************
 3
 4SELECT * FROM sys.objects o
 5WHERE 
 61 != 1 OR
 71>1 OR
 80 > 1 OR
 91 = 0 OR
100 != 0 OR 
112!=2 OR 
122<>2 OR 
132<1 OR 
142<=1 OR 
152<>2.0 OR 
162.0<1.0 OR 
172<=1 OR 
18
191>=2 OR 
20
21object_id != [object_id]  OR 
22o.object_id != o.[object_id]  OR
23'A'<'A' OR
24'A'!='A' OR
25'B'<>'B' OR
26'B'<>N'B' OR
27'ab' != 'ab' OR
28'ab' != N'ab' OR
29'ab' < N'a' OR
30'ab' < N'a' OR 
31'ab' = N'a' OR 
32'ab' < 'a' OR
33'ab' < 'a' OR 
34'ab' = 'a' OR 
35name != name OR
36name <> name OR
37name < name OR
38o.[name] > o.name OR
39name NOT LIKE name OR 
401 IN (2,4,3) OR 
41'a' IN ('b','c','d', 6) OR
421 NOT IN (1, 2,4,3, 2-1) OR 
431 IN (2,4,3) OR 
44'a'  NOT IN ('b','c','d','a' ) OR
45NOT Exists (SELECT 0)
46
47IF 1 > 1
48BEGIN
49    SELECT * FROM sys.objects
50    WHERE 
51    object_id != [object_id] OR 
52    sys.objects.object_id != sys.objects.[object_id] OR
53    object_id <> [object_id] OR 
54    sys.objects.object_id <> sys.objects.[object_id] OR
55    object_id > [object_id]  OR 
56    sys.objects.object_id < sys.objects.[object_id] 
57END
58
59-- NOTE:The expressions are not evaluated
60SELECT * FROM sys.objects
61WHERE
621 NOT IN (0, 2,4,3, 2 - 1) OR
63'a' IN (SELECT 1) OR
641 IN (2,4,3, 2-1)
65
66SELECT * FROM sys.objects WHERE Exists (SELECT 0 WHERE 1 = 0) 
67SELECT * FROM sys.objects WHERE NOT Exists (SELECT 0 WHERE 1 = 1)

Analysis Results

 MessageLineColumn
1SA0039 : The comparison expression evaluates to FALSE.399
2SA0039 : The comparison expression evaluates to FALSE.402
3SA0039 : The comparison expression evaluates to FALSE.414
4SA0039 : The comparison expression evaluates to FALSE.426
5SA0039 : The comparison expression evaluates to FALSE.432
6SA0039 : The comparison expression evaluates to FALSE.449
7SA0039 : The comparison expression evaluates to FALSE.454
8SA0039 : The comparison expression evaluates to FALSE.62
9SA0039 : The comparison expression evaluates to FALSE.71
10SA0039 : The comparison expression evaluates to FALSE.82
...
45SA0039 : The comparison expression evaluates to FALSE.5626
46SA0039 : The comparison expression evaluates to FALSE.6657
See Also

Other Resources