That is a fun one with NULLs. The problem is that @x=@tempX can be true or false when either of those is NULL. Doing a comparison on if @x=NULL or a comparison on not(@x=NULL) will give you false to both. It is because NULL is an unknown value.
Try this query:
@x INT = 1
WHEN @x = NULL
WHEN NOT (@x = NULL)
and you will see it is "0" for both columns. This is because NULL is an unknown value. SQL is seeing NULL as any possible value. With the first query, there is a value for NULL where @x will not equal NULL and that is any value other than 1. In the second query, there is a value for NULL such that @x will equal NULL and that is the value 1. Since NULL is an unknown, doing a comparison on NULL, SQL will give you a consistent result as you have seen.
A better approach is to use ISNULL and give the variable a value. Fun thing, if you set @x to NULL, you still get 0 in both columns. this is because NULL does not equal NULL, but also could equal NULL.
This is one of the many reasons why NULL is bad to have in a table unless "unknown" is a valid value. NULL, in SQL Server, should be treated as an unknown value that may or may not equal what you are comparing.