Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Query Not Working
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01400408
Message ID:
01400432
Vues:
35
This is George's answer on this problem:

--------------------------------------------------
This happens because the 2nd version will not return rows where the data is null.

Declare @Temp Table(Data Int)

Insert Into @Temp Values(NULL)
Insert Into @Temp Values(1)
Insert Into @Temp Values(2)

Declare @Search Int

Set @Search = NULL

Select * From @Temp Where (@Search Is NULL Or Data = @Search)

Select * From @Temp Where Data = IsNull(@Search, Data)


The second query will return 2 rows instead of 3.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform