I\'m looking for a query which will return me an extra column at the end of my current query which is the count of all columns within the return set which contain a null column.
You can use computed column:
CREATE TABLE testTable(
col1 nchar(10) NULL,
col2 nchar(10) NULL,
col3 AS (case when col1 IS NULL then (1) else (0) end+case when col2 IS NULL then (1) else (0) end)
)
It is not a pretty solution, but should work.
If you are dealing with a big number of columns and many of them you expect to be NULL then you could use sparse columns (available in SQL Server 2008). It will be optimised for NULL and it can automatically generate XML representation for each row of data in the table.