Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SP parameter use = '' or NULL ?
Message
De
27/07/2005 23:19:28
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Divers
Thread ID:
01036110
Message ID:
01036473
Vues:
15
Hi Sergey,

Thank, so

01) I advise developer to use NULL insteads of '' and use default as NULL
for the parameter, is that right ?

02) On the other hand, why is the SP code, if (LEN(@para1) > 0) become true
when @para1 = '' ?. Why ? Currently, i am using if(len(@para1) > 2) to check
for any parameter pass in and if(len(@para1) = 2) to check for empty parameter as changes to my system now is too big a impact.




>I prefer Null as default for aparameter. This way you don't even have to pass parameter in. Checking for null value seems more clean to me then len(@para1).
>
>>Why is it that SP passing in parameter of '' end up with LEN() giving 1
>>in the SP when it is empty('') string ?
>>
>>For example, my sample SP
>>
>>Create store procedure Test(@para1 char(10), @para2 char(10))
><snip>
>>
>>Therefore, what is the best way to pass in a parameter if it is empty, do we set
>>it to NULL for default or pass in NULL if it is empty. Please advise
Best Regards
Virusim
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform