Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ANSI_NULLS comparison problem
Message
De
30/01/2007 03:29:33
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Divers
Thread ID:
01190063
Message ID:
01190379
Vues:
15
Sergey,

In so many words - Thank's!

>The ELSE in the first example is never executed when SET ANSI_NULLS OFF.
>SELECT #Temp.*,
>   CASE WHEN (#Temp.S1 = #Temp.S2) OR COALESCE(#Temp.S1,#Temp.S2) IS  NULL THEN 1
>        ELSE 2  END AS S3 From #Temp
>
>>
>>-- Example 1
>>SET ANSI_NULLS OFF
>>
>>Declare @x Integer, @y INTEGER
>>SET @y = 0
>>SELECT @x AS S1, @y AS S2, CASE WHEN @x = @y THEN 1 WHEN @x <> @y THEN 2 ELSE NULL END AS S3
>>
>>-- Produces NULL 0 2
>>
>>-- Example 2
>>Create Table #Temp (S1 Int, S2 Int)
>>Insert into #Temp (S1) Values (NULL)
>>Update #Temp Set S2 = 0
>>Select #Temp.*,
>>   CASE WHEN #Temp.S1 = #Temp.S2 THEN 1
>>      WHEN #Temp.S1 <> #Temp.S2 THEN 2
>>      ELSE NULL
>>   END AS S3 From #Temp
>>-- Produces NULL 0 NULL
>>
>>
>>How can I make sure that the Null comparison is as in Example 1?
>>
>>BR
Peter Pirker


Whosoever shall not fall by the sword or by famine, shall fall by pestilence, so why bother shaving?

(Woody Allen)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform