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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:00:41+00:00 2026-06-18T07:00:41+00:00

I have a bit column on a table in a SQL Server 2012 database.

  • 0

I have a bit column on a table in a SQL Server 2012 database.

I am trying to retrieve all the rows where this bit column is either NULL or NOT TRUE.

This query does not bring back what it should: (returns 0 rows)

Select * 
from table 
where bit_column_value <> 1

This query brings back the correct rows:

Select * 
from table 
where bit_column_value IS NULL

Now, I’d be happy to use the second query, but my issue is that, in a similar query for another table, the reverse of the above is true, where the first way works, but the second way does not!

Could someone assist in explaining what the difference is in the above? I have specifically updated the relevant bit columns to be NULL and this does not change the results. (Thought maybe there was a difference between “Empty” and Null values.

Thanks in advance for any explanations.

  • 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-06-18T07:00:43+00:00Added an answer on June 18, 2026 at 7:00 am

    The reason <> doesn’t work is that SQL treats NULL as unknown – it doesn’t know what NULL is supposed to mean, so it evaluates both = and <> on a NULL value as UNKNOWN (which is treated as false in a where clause or join condition). For more info, read this: Why does NULL = NULL evaluate to false in SQL server.

    If there’s an index on it, using the ISNULL function will mean the index can’t be used, so to
    ensure the query can use the index just use OR:

    SELECT * 
    FROM TableName
    WHERE
       bit_column_value IS NULL OR bit_column_value = 0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQL Server 2008 database. This database has a column that represents
I have a nullable DateTime column in my SQL Server 2005 table called DateTimeDeleted.
I have a table Messages in SQL Server 2012. There are three columns in
Current Implementation Sql Server 2005 Database with a table called messages with a column
I'm creating a table that'll have a single bit not null column IsDefault .
I have a SQL Server table and I'm trying to make sense of fulltext
I have a table where one of the fields is InDatabase (SQL Server bit
In SQL Server, I have a new column on a table: ALTER TABLE t_tableName
I have a SQL Server table containing a TEXT column and a DATETIME column
I have an INT column in a SQL Server database which stores a value

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.