I have a query that looks something like this:
select *
from resident
where Resident_Sex is null or Resident_Date_Of_Birth is null or race_code is null.
not always is it only checking if 3 columns are null, it may have more. I want to know if there is a way, instead of selecting * from this table, to select lets say the resident id and the column name that he is missing.
for example, it should return
resident_id column_name
----------- ------------
aaaaaaa resident_sex
bbbbbbb resident_sex
bbbbbbb race_code
ccccccc resident_date_of_birth
instead of returning
resident_id resident_sex race_code Resident_date_of_birth
----------- ------------ ----------- -----------------------
aaaaaaa null 158 1995-02-18 00:00:00.000
bbbbbbb null null 1928-07-15 00:00:00.000
ccccccc F 12 null
Obviously there are alot more rows and columns in the table so I cannot do any case or if statements...
I hope I made myself clear... thank you in advance!