1st situation:
Why the Case statement returns 1 as output in this situation. First I checked with this query:
DECLARE @VAR INT=0
SELECT CASE
WHEN @VAR = ' ' THEN 1
ELSE 0
END as empty_string
Output :
empty_string
1
After this situation, I tried like this:
Second situation:
Why does a different value arise when assigning a Local variable?
DECLARE @var1 INT =' '
SELECT @var1 AS empty_assighn
SELECT ' ' AS empty_string
OUTPUT
empty_assighn
0
empty_string
Then I found that whenever it is assigned, it takes '' (empty string) as a null value. Therefore, I get 1 as output in the 1st situation. But why is this so? What is the reason for this?
Thank you in advance
source
share