I've got a table with measurement data in SQL Server 2005, one value per person and year, if available. My TSQL code fetches these values in a loop and processes them:
...
SET @val = (SELECT measurement FROM tbl_data WHERE persid = @curpersid AND yr = @curyear)
...
Now, for a certain person and year, the table can contain (i) a valid measurement, (ii) a NULL value or (iii) no corresponding row at all.
How do I differentiate between these cases efficiently? Both (ii) and (iii) will result in @val being NULL, so with the current code, they can't be differentiated...
Thanks a bunch for any hints, wwwald