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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:04:05+00:00 2026-05-27T11:04:05+00:00

I had a strange error where I did something like the following: SELECT *

  • 0

I had a strange error where I did something like the following:

SELECT *
FROM table1
WHERE NAME COLLATE LATIN1_General_CI_AS NOT IN (select name FROM table2)

Name was a nvarchar(50) null. Table2 had null values in the name column. It would then match names that did not exist in table2 because of the null values. Meaning that this would return 0 results. And if I did:

SELECT *
FROM table1
WHERE NAME COLLATE LATIN1_General_CI_AS NOT IN (
  select name FROM table2 where name is not null
)

I would get some results.

One table had collation Danish_Norwegian_CI_AS and the other one latin1. Maybe the COLLATE is the source of the problem?

Can anyone explain why this happens? Maybe something with set theory?

  • 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-27T11:04:06+00:00Added an answer on May 27, 2026 at 11:04 am

    It has nothing to do with collation. Try set ansi_nulls off and the first query will work as you expected.

    The reason is that when you try to compare something to NULL (e.g. a = NULL or a <> NULL) the result is UNKNOWN and the entire query fails. If you set ansi_nulls to off then the same comparison evaluates to TRUE or FALSE and the query “works”.

    In other words:

    WHEN a NOT IN (1, 2, null)
    

    means

    WHEN a <> 1 AND a <> 2 AND a <> null
    

    WHERE the last part a <> null evaluates to UNKNOWN and the query fails to return any rows.

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

Sidebar

Related Questions

I know it is a strange question did someone have had a case where
I switched from Visual Studio to Code::Blocks yesterday, and just had some strange compiler
I came across a strange error when using NGen from .NET Framework 4 to
a few days we had a strange error with sqlite. We use a sqlite
I've been getting a strange error that has had me hung up all morning.
Subversion has very strange behavior when moving/deleting folder. I had this error Subversion unreliable:
I was writing an XPath expression, and I had a strange error which I
I have a strange timeout error, but I'm not sure how to debug it.
In a calling to an OpenGL function, I had the following error: error C2664:
Ok, here is something strange that has had me stumped for about 45 minutes...

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.