-2

I would like to select rows from database where the ArkivDate is null.

I tried this:

SELECT
    * 
FROM
    [Bums].[dbo].[Items] 
INNER JOIN 
    [Bums].[dbo].[ItemsArkivFormUsed] ON [Bums].[dbo].[ItemsArkivFormUsed].[ItemNumber] = [Bums].[dbo].[Items].[ItemNumber] 
WHERE 
    [Bums].[dbo].[ItemsArkivFormUsed].[ArkivDate] = null

The query works if I remove the WHERE clause, but when I include it, the result returns empty.

I'm wondering, have I misplaced the WHERE?

The tables does have some null ArkivDate but my query can't filter to only display them

Can I anyone help me please

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Simon.S
  • 107
  • 1
  • 1
  • 9

1 Answers1

2

NULL is a strange beast in sql, you need to use the syntax IS NULL rather than = NULL when ANSI_NULLS is set to on, which is the default.

SELECT * FROM [Bums].[dbo].[Items] 
INNER JOIN [Bums].[dbo].[ItemsArkivFormUsed] 
    ON [Bums].[dbo].[ItemsArkivFormUsed].[ItemNumber] = [Bums].[dbo].[Items].[ItemNumber] 
WHERE [Bums].[dbo].[ItemsArkivFormUsed].[ArkivDate] IS NULL

See docs on SET ANS_NULL for more info

Jamiec
  • 133,658
  • 13
  • 134
  • 193