Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Null in where clause
Message
De
23/02/2001 09:23:35
 
 
À
22/02/2001 14:16:38
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00478555
Message ID:
00478804
Vues:
17
WHERE mydatefield = @dateparm OR mydatefield is null

Why doesn't that work?

>Hi,
>
>assume: mytable.mydatefield - mydatefield can be null
>
>Is there any way that I can write in ONE where clause a statement to find all records in mytable where mydatefield 'equals' a passed in parameter, and that parameter can either be a date value or null?
>
>currently - I have to test to see if the parameter is null or not and either run "where mydatefield = @dateparm" or "where mydatefield IS null". This requires either two different statements or dynamic SQL - and since the real query is much longer and inside a case statement, ... well - you get the point ....
>
>Life would be SO MUCH EASIER if T-SQL simply understood "where mydatefield = @dateparm" and @dateparm could be null and would return all recs where the datefield was null.
>
>Any help much appreciated.
>
>TIA!
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform