Create A Query To Check If Any Column In A Table Is Null
I have zero experience with SQL but am trying to learn how to validate tables. I am trying to see within a table if any of the columns are null. Currently I have been going with a
Solution 1:
You can count each column in a single query by using sum and case:
select
sum(case when Column1 is null then 1 else 0 end) Column1NullCount
, sum(case when Column2 is null then 1 else 0 end) Column2NullCount
-- ...
, sum(case when ColumnN is null then 1 else 0 end) ColumnNNullCount
from MyScheme.MyTable
Post a Comment for "Create A Query To Check If Any Column In A Table Is Null"