I got the answer right because I was looking at the logic, 'where 1=0'.
But when I changed it to 'where 1=1', the output came out as 0.
If a 'A SELECT statement that doesn't return results doesn't set a variable to anything.', then why didn't it remain at 1 when I changed the logic to 'where 1=1' ?
I hope I don't sound terrible naive about this. Below is the code I used to check the veracity of the statement:
DECLARE @i INT
SELECT @i = 1
SELECT @i = 0 where 1=0
SELECT @i as i
SELECT @i = 1
SELECT @i = 0 where 1=1
SELECT @i as i
SELECT @i
May I ask for further enlightenment? Thank you.