Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6579329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:53:04+00:00 2026-05-25T15:53:04+00:00

Code analysis rule SR0007 for Visual Studio 2010 database projects states that: You should

  • 0

Code analysis rule SR0007 for Visual Studio 2010 database projects states that:

You should explicitly indicate how to handle NULL values in comparison expressions by wrapping each column that can contain a NULL value in an ISNULL function.

However code analysis rule SR0006 is violated when:

As part of a comparison, an expression contains a column reference … Your code could cause a table scan if it compares an expression that contains a column reference.

Does this also apply to ISNULL, or does ISNULL never result in a table scan?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:53:05+00:00Added an answer on May 25, 2026 at 3:53 pm

    Yes it causes table scans. (though seems to get optimised out if the column isn’t actually nullable)

    The SR0007 rule is extremely poor blanket advice as it renders the predicate unsargable and means any indexes on the column will be useless. Even if there is no index on the column it might still make cardinality estimates inaccurate affecting other parts of the plan.

    The categorization of it in the Microsoft.Performance category is quite amusing as it seems to have been written by someone with no understanding of query performance.

    It claims the rationale is

    If your code compares two NULL values or a NULL value with any other
    value, your code will return an unknown result.

    Whilst the expression itself does evaluate to unknown your code returns a completely deterministic result once you understand that any =, <>, >, < etc comparison with NULL evaluate as Unknown and that the WHERE clause only returns rows where the expression evaluates to true.

    It is possible that they mean if ANSI_NULLS is off but the example they give in the documentation of WHERE ISNULL([c2],0) > 2; vs WHERE [c2] > 2; would not be affected by this setting anyway. This setting

    affects a comparison only if one of the operands of the comparison is
    either a variable that is NULL or a literal NULL.

    Execution plans showing scans vs seek or below

    CREATE TABLE #foo
      (
         x INT NULL UNIQUE
      )
    
    INSERT INTO #foo
    SELECT ROW_NUMBER() OVER (ORDER BY @@SPID)
    FROM   sys.all_columns
    
    SELECT *
    FROM   #foo
    WHERE  ISNULL(x, 10) = 10
    
    SELECT *
    FROM   #foo
    WHERE  x = 10
    
    SELECT *
    FROM   #foo
    WHERE  x = 10
            OR x IS NULL 
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Its said that property should not be Set only (Code analysis rule CA1044 )and
I have a small issue with the Code Analysis in Visual Studio 2010. I'm
Visual Studio added code analysis ( /analyze ) for C/C++ in order to help
I'm trying to write a custom FxCop code analysis rule that will warn developers
I'm using Visual Studio 2010 Ultimate, and it seems that I cannot suppress warnings
I am using code analysis tool of VS 2010..two things that i have noticed
I have a problem with the code analysis rule CA1726:UsePreferredTerms . Our business domain
What code analysis tools do you use on your Java projects? I am interested
I have several Code Analysis CA1704:IdentifiersShouldBeSpelledCorrectly warnings that I want to suppress. Basically, they
What are the basic minimum set of Code Analysis rules that you would recommend

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.