Skip to content
Advertisement

Number of Null and non-null values for each column in SQL for a given table

I am trying to find the number of null values, non-null values, total rows for each column in a table named StudentScore.

Code to create table:

Code to find number of null, non null, total rows for each column in the table:

I am getting below errors:

Result I need:

Advertisement

Answer

The reason for the error is that INFORMATION_SCHEMA.COLUMNS does not contain columns dbo and StudentTable, so using QUOTENAME(dbo), QUOTENAME(StudentScore) and WITHIN GROUP(ORDER BY dbo, StudentScore) is an eror.

If you want to count the NULL and NOT NULL values for NULLABLE columns for one specific table, the statement should be:

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