The work of your sample code
According to SQL Fiddle, this works. It is either set to 0 or 1. Therefore, if you use exactly the code that you show us, this variable cannot be null .
declare @AdminApproved1 bit declare @AdminApproved2 bit select @AdminApproved1 = case when (null) is null then 0 else 1 end, @AdminApproved2 = case when (getdate()) is null then 0 else 1 end
But the variable can still be null
So, if your sample code is not complete, I can show you another example where both top variables will be null even after select executed. And I suspect your problem is related.
declare @AdminApproved1 bit declare @AdminApproved2 bit select @AdminApproved1 = CASE WHEN (null) IS NULL THEN 0 ELSE 1 END, @AdminApproved2 = CASE WHEN (getdate()) IS NULL THEN 0 ELSE 1 END from SomeTable where 0 = 1
source share