Hey,
I was playing around with SQL (SQL Server 2008) toady and noticed something I think is really strange:
Why is this operation allowed? Why is any mathematical operation allowed on NULL?
NULL as I know it in programming is an undefined value. In math, when dividing by 0 you get an undefined value.
Thus NULL = x/0 ?
SQL does throw divide by 0 exceptions, so why are division by NULL or comparison to NULL exceptions not raised?
PS: Please excuse me if this is a silly question, but I generally don't program anything other than the standard CRUD statements in SQL.
I was playing around with SQL (SQL Server 2008) toady and noticed something I think is really strange:
Code:
select 1/null -- returns null
NULL as I know it in programming is an undefined value. In math, when dividing by 0 you get an undefined value.
Thus NULL = x/0 ?
SQL does throw divide by 0 exceptions, so why are division by NULL or comparison to NULL exceptions not raised?
PS: Please excuse me if this is a silly question, but I generally don't program anything other than the standard CRUD statements in SQL.
Comment