0

I have code...

DECLARE @y AS INT = xxx; --IF THIS IS NULL THEN WE WANT EVERYTHING RETURNED

SELECT column
FROM   table
WHERE  y >= @y; 

How can I set this up so that IF @y IS NULL then the where clause is ignored and everything is returned?

1 Answer 1

3
SELECT some_column
FROM your_table
WHERE (@y is null or y >= @y)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.