Reputation: 5987
The actual result of the following Query is NULL
select semid from programvariantterm where programvariantid = 240
But when I try the following statement, it gives 0 rows:
declare @semid int
set @semid = -1
select semid from programvariantterm
where programvariantid = 240 and semid = nullif(@semid,-1)
Upvotes: 0
Views: 1136
Reputation: 41539
I think you're confusing NULLIF
and ISNULL
a little bit.
Your statement would work with the following ISNULL
:
where programvariantid = 240 and @semid = ISNULL(semid,-1)
Upvotes: 2