TopAnswers Databases
or
I have a question about this fiddle:

<>https://dbfiddle.uk?rdbms=sqlserver_2019&fiddle=5fb4c089af3d52e645aade8970793767

Is it ever possible to get -1 as the result of this query? 
I think no, right because potato can be either null or not null and the case covers both scenario? 

sql server 11 

Sincerely, 
Top Answer
CC BY-SA 4.0Ami
You are correct.

The CASE conditional expression can evaluate to either 1 or 0, never to a NULL.

The encapsulating ISNULL function will always see a concrete value, `1` or `0`, and so will never return `-1`.

If you explain what you are trying to achieve with this code that doesn't seem to work for you, we may be able to offer some advice.
ypercubeᵀᴹ
@Ami I edited the answer. The isnull can return 1 or 0, whatever the case returns. It is true that it can never return -1.
Lamak replying to Anonymous
that fiddle seems to work fine?
Anonymous
https://dbfiddle.uk/?rdbms=sqlserver_2012&fiddle=d184d1b358b81986fa8b0c2abc86eae9
Anonymous
the real code is not much more complex than this. just trying to understand if I am missing something... 
Max
have you tried `set @potato = null;` and seeing what is returned?  Also, try removing the `set` statement altogether.  This seems like a pretty easy thing to prove.  If you have a more complex scenario in reality, please post that.  Cheers!