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 719239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:37:09+00:00 2026-05-14T05:37:09+00:00

This is a problem one of our developers brought to me. He stumbled across

  • 0

This is a problem one of our developers brought to me. He stumbled across an old stored procedure which used ‘WHERE col = NULL’ several times. When the stored procedure is executed it returns data.

If the query inside the stored procedure is executed manually it will not return data unless the ‘WHERE col = NULL’ references are changed to ‘WHERE col IS NULL’.

Can anyone explain this behavior?

  • 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-14T05:37:09+00:00Added an answer on May 14, 2026 at 5:37 am

    That’s by design: if you compare anything to null, it evaluates to unknown. Any logic with unknown is itself unknown. So any statement with anything = null will always be false.

    The important difference is between these two constructs:

    1 = null --> unknown
    1 is null --> false
    

    So:

    1 = null or 1=1 --> unknown (false)
    1 is null or 1=1 --> true
    

    So as you can see, unknown taints an entire expression.

    Based on the comments, a better answer would probably be checking for ANSI_NULLs, with:

    SELECT SESSIONPROPERTY ('ANSI_NULLS')
    

    If this returns false, the = null construct would work like is null:

    set ansi_nulls on -- default
    SELECT SESSIONPROPERTY ('ANSI_NULLS') -- 1
    select 1 where not null = 1 -- no rows returned
    set ansi_nulls off
    SELECT SESSIONPROPERTY ('ANSI_NULLS') -- 0
    select 1 where not null = 1 -- returns a row
    

    The default is ansi_nulls on though, and it’s very unusual to see it turned off. A stored procedure does remember the setting from the time it was created:

    set ansi_nulls off
    go
    create procedure dbo.TestNulls as select 1 where not null = 1
    go
    set ansi_nulls on
    exec dbo.TestNulls -- Still prints a row
    

    You can check the saved settings by scripting the procedure from SSMS.

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

Sidebar

Related Questions

We are currently using JDeveloper to build our production EARs. One problem with this
So i'm having this problem. I have two tables (Oracle), one is called Destination
My problem is this one, I am using Sharepoint 2010, I have a form
I am having a problem like this one: http://svn.haxx.se/tsvnusers/archive-2008-07/1051.shtml Except that the app is
I'm skinning scrollbar in my flex app and got one problem. This white square
This is my problem, I have one textbox, one button and one label. Everything
From this post . One obvious problem is scalability/performance. What are the other problems
The problem is this, I include a script, it uses another one, but what
This one seems to be a simple problem, but I can't make it work
One of our developers is continually writing code and putting it into version control

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.