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

  • SEARCH
  • Home
  • 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 7669575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:37:29+00:00 2026-05-31T15:37:29+00:00

The definition says: When SET ANSI_NULLS is ON, a SELECT statement that uses WHERE

  • 0

The definition says:

When SET ANSI_NULLS is ON, a SELECT statement that uses WHERE column_name = NULL returns zero rows even if there are null values in column_name. A SELECT statement that uses WHERE column_name <> NULL returns zero rows even if there are non-null values in column_name.

Does this mean that no nulls will be included in this query?

SELECT Region
FROM employees
WHERE Region = @region

Or do ANSI_NULLs concern only queries like this one (where the WHERE includes the specific word NULL)?

SELECT Region
FROM employees
WHERE Region = NULL
  • 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-31T15:37:30+00:00Added an answer on May 31, 2026 at 3:37 pm

    It means that no rows will be returned if @region is NULL, when used in your first example, even if there are rows in the table where Region is NULL.

    When ANSI_NULLS is on (which you should always set on anyway, since the option to not have it on is going to be removed in the future), any comparison operation where (at least) one of the operands is NULL produces the third logic value – UNKNOWN (as opposed to TRUE and FALSE).

    UNKNOWN values propagate through any combining boolean operators if they’re not already decided (e.g. AND with a FALSE operand or OR with a TRUE operand) or negations (NOT).

    The WHERE clause is used to filter the result set produced by the FROM clause, such that the overall value of the WHERE clause must be TRUE for the row to not be filtered out. So, if an UNKNOWN is produced by any comparison, it will cause the row to be filtered out.


    @user1227804’s answer includes this quote:

    If both sides of the comparison are columns or compound expressions, the setting does not affect the comparison.

    from SET ANSI_NULLS*

    However, I’m not sure what point it’s trying to make, since if two NULL columns are compared (e.g. in a JOIN), the comparison still fails:

    create table #T1 (
        ID int not null,
        Val1 varchar(10) null
    )
    insert into #T1(ID,Val1) select 1,null
    
    create table #T2 (
        ID int not null,
        Val1 varchar(10) null
    )
    insert into #T2(ID,Val1) select 1,null
    
    select * from #T1 t1 inner join #T2 t2 on t1.ID = t2.ID and t1.Val1 = t2.Val1
    

    The above query returns 0 rows, whereas:

    SELECT * FROM #T1 t1 INNER JOIN #T2 t2 
       ON t1.ID = t2.ID 
      AND (   t1.Val1 = t2.Val1 
           OR t1.Val1 IS NULL 
          AND t2.Val1 IS NULL   )
    

    Returns one row. So even when both operands are columns, NULL does not equal NULL. And the documentation for = doesn’t have anything to say about the operands:

    When you compare two NULL expressions, the result depends on the ANSI_NULLS setting:

    If ANSI_NULLS is set to ON, the result is NULL1, following the ANSI convention that a NULL (or unknown) value is not equal to another NULL or unknown value.

    If ANSI_NULLS is set to OFF, the result of NULL compared to NULL is TRUE.

    Comparing NULL to a non-NULL value always results in FALSE2.

    However, both 1 and 2 are incorrect – the result of both comparisons is UNKNOWN.


    *The cryptic meaning of this text was finally discovered years later. What it actually means is that, for those comparisons, the setting has no effect and it always acts as if the setting were ON. Would have been clearer if it had stated that SET ANSI_NULLS OFF was the setting that had no effect.

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

Sidebar

Related Questions

I am working on a C program that uses a Union. The union definition
I am getting an error that says: 'object' does not contain a definition for
The definition I found for the blueprint css class called .column says: .column Use
The language reference says Name of CSS style declaration that specifies styles for the
I read this [useful article] that says I can create a library of inline
What is the difference between these two listeners,documentation says : OnItemSelectedListener - Interface definition
The documentation says: $ play start Note: the HTTP port can be set by
Definition of variables in use: Guid fldProId = (Guid)ffdPro.GetProperty(FieldId); string fldProValue = (string)ffdPro.GetProperty(FieldValue); FormFieldDef
Definition of SUCCEEDED(): #define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0) Background: When an Ok button is
By definition algorithms are independent from the medium they run on. E.g. I use

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.