I want to find out which column having null value in a entire table. In table schema all columns has allows null but in table only few columns having null how to figure out those columns .
I tried with Collate function (Select * from Table_name where COLLATE(column1,column2,...columnN) IS NULL it shows syntax error near collate
I want to find out which column data having null value in a table
3条答案
按热度按时间im9ewurl1#
I think if you try to use
COALESCE
instead ofCOLLATE
, sinceCOALESCE(att1, att2, att3)
return the first value that is not null, your code will return all rows where everything isNULL
.You can try to return every rows where there's a
NULL
value :or for every column, you count the non-null values :
Every
COUNT(colX)
with a different value thanCOUNT(*)
containsNULL
valueseqzww0vc2#
Use this to figure out which columns have at least one null value:
cclgggtu3#
Here is a generic way to determine columns that have NULL values in all rows in a table.
SQL
Output