Is there a way to select the column names of a certain table except those columns with only null values without knowing how many columns the table have.
-------------------------
| col1 | col2 | col3 |
------------------------
| val1 | null | val2 |
| val1 | null | null |
| null | null | val2 |
-------------------------
Should result in:
------------------------------------
| cols_except_those_with_null_only |
-----------------------------------
| col1 |
| col3 |
------------------------------------
Thanks!
Create a stored procedure with following content:
Try this, it's not the tidiest but will work, just set
@Table
to your table name.With this structure you can do a query in a store procedure that allows you to ask for each column name of the table and if it has null values without caring how many columns your table has