What are the challenges you face when working across database platforms? Take the survey
Options

Code Analysis feedback - EI003 false positive and too restrive PE006

I got some feedback for the code analysis tool on one of our bigger code bases which for a first use worked great.

1. false positive for rule "EI003" - Non-scalar subquery in place of a scalar

Repro. The analyse trips of the union in the following example

DELETE FROM
dbo.Person
WHERE
PersonID NOT IN (
SELECT
par.Person_ID
FROM
dbo.PersonAccountRole par
WHERE
par.Person_ID IS NOT NULL
UNION
SELECT
Buyer_Decision_Maker
FROM
dbo.TransactionNL
WHERE
Buyer_Decision_Maker IS NOT NULL
)

2. Misplaced warning (IMO) for rule PE006 - TABLE HINT is used

Repro. A readuncommitted hint (nolock) or any other isolation level hint is not in scope of this otherwise good advice.

SELECT * FROM Lookup.Person WITH (READUNCOMMITTED)

A nolock is common use for reports or diagnostic queries.

The description of this rule is

"
It is not a good idea to use any of the rich variety of table hints.
The SQL Server query optimizer usually selects the best index for a join, so these be used only as a last resort by experienced
developers and database administrators.
"

Agreed that, as in the the description, when a MERGE/LOOP/HASH join hint is used a warning is appropriate.

3. Is it possible to disable a rule with a comment so that the rule applies in general but not on some lines?

Kind Regards, Tom


Tagged:

Comments

Sign In or Register to comment.