|
Posted by helmut woess on 03/01/06 14:11
Am 1 Mar 2006 01:57:11 -0800 schrieb Shwetabh:
> Hi,
>
> My question is, is there any difference between a NULL and a Blank
> (Unknown, Not Applicable) field in MS SQL or are they the same?
>
> Awaiting your comments,
> Regards
Yes, a very big difference! Be carefully if you have NULL valued fields. If
you do a compare and one or both are NULL, then the result is always NULL,
never true or false. Even comparing two fields which are both NULL will
give NULL as result, not true! Or if you have something like "select
sum(field) from ..." and one or more are NULL, then the result will be
NULL. Use always "if field is NULL ..." for NULL checking and for safety
maybe something like "select sum( IsNull(field,0) ) from ...". Check the
function ISNULL() in the manual.
bye,
Helmut
[Back to original message]
|