0

I have the following query :

DECLARE @dt AS DATE = NULL;

SELECT orderid, shippeddate
FROM Sales.Orders
WHERE shippeddate = @dt;

I have some Orders with NULL shippeddate but they are not returned when executing the above query.

1

2 Answers 2

3

You need to check for NULL using IS NULL. So:

WHERE shippeddate = @dt OR (shippeddate IS NULL AND @dt IS NULL)
Sign up to request clarification or add additional context in comments.

Comments

1
DECLARE @dt AS DATE = NULL;

SELECT orderid, shippeddate
FROM Sales.Orders
WHERE shippeddate = @dt  or (shippeddate IS NULL AND @dt IS NULL)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.