0

I have seen the solutions here:

Count of non-null columns in each row

My own initial instinct was using case statements. But I have far more than 4 columns and I want to repeat this process on four different tables. Is there a way to repeat the process with some kind of loop through all columns rather than naming each of them explicitly?

redchief
  • 11
  • 1
  • 4
  • 1
    It would take dynamic sql to do that. Any by the time you have built the dynamic sql you could just code these yourself. – Sean Lange Jan 22 '18 at 20:10
  • Not the answer I was hoping for, but thank you. My work around now is using select * to get all the column names, then running a concatenate in VBA to build a case statement around each column name. It is hackish, but it works, and it is quickly reusable as I tinker with the case statement (I may find nulls aren't the only values I want to exclude in my count later on). – redchief Jan 22 '18 at 21:52

0 Answers0