Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How To Handle No Params Passed
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 6.5 and older
Divers
Thread ID:
01359989
Message ID:
01360221
Vues:
7
>Kevin,
>
>We use the COALESCE() function, it makes the code a whole lot easier to maintain, here's an example:
>
>WHERE p.AppKey                 = COALESCE(@AppKey, p.AppKey) 
>  AND pc.CategoryTypeKey       = COALESCE(@CategoryKey,pc.CategoryTypeKey  
>  AND psc.ProjectStatusCodeKey = COALESCE(@StatusKey,psc.ProjectStatusCodeKey)
>
>
>Basically for each variable, if the variable is null, then it will retrieve all values, otherwise it will only pull in records that match the variable. It is very easy to add additional filter criteria.
>
>Kurt

Exactly what I was saying before John came along :) You can use either COALESCE or ISNULL here, it doesn't matter - your preference.
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