Skip to content
Advertisement

sql query to exclude not null columns

I have below table and records

Now i do not want to display the rows having null values in the columns except primary key column.

I used below query to arrive the above result.

But my orginal table having 72 columns how can i check all the columns for getting above result.

/

Advertisement

Answer

You could check the length of CONCAT this way (but it treats empty strings and NULLs the same):

You could build that CONCAT list this with dynamic SQL:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement