Friday, March 23, 2007

MSSQL Handling NULL Values

One of the most horrific problems in database-access are fields which allow Null-values, I remember all the IF statements it took in COBOL to handle this problem (with a CSV file) and I was afraid I had to go through the same hell as back then. By making use of the ISNULL method we were able to remove the evil at it's root, the database...

An example :

SELECT username, ISNULL(email,"") FROM tblUser

This query will set the emailadres to an empty string instead of a null value if no value is entered.
Since the abilities to handle Null values with Typed Datasets are rather limited, this was a fine solution..

1 comment:

Anonymous said...

Thanks!, solved my issue :)