No. There are ways to code it quicker, but there are no shortcuts like you imply. Taken from an answer I gave on dba.stackexchange:

DECLARE @tb NVARCHAR(255), @sql NVARCHAR(MAX);

SET @tb = N'dbo.[table]';

SET @sql = N'SELECT * FROM ' + @tb + ' WHERE 1 = 0';

SELECT @sql = @sql + N' OR ' + QUOTENAME(name) + ' IS NULL'
    FROM sys.columns 
    WHERE [object_id] = OBJECT_ID(@tb);

EXEC sp_executesql @sql;
Answer from Aaron Bertrand on Stack Overflow
Discussions

Check if columns are NULL or contains NULL in table. - MS SQL Server - Stack Overflow
Following is my table (TestTable) where Column_3 is NULL. Column_1 Column_2 Column_3 -------- -------- -------- 1 2 NULL 1 3 NULL 5 6 NULL As per functio... More on stackoverflow.com
🌐 stackoverflow.com
Counting rows where ALL columns are either null or empty in the row?
What are the data types? Are they all string types (your example seems to imply that)? Based on https://www.sqlservercentral.com/forums/topic/how-to-get-all-rows-of-a-table-having-null-in-all-columns: You could use something like ISNULL(COALESCE(Col1,Col2,Col3,Col4),'') = '' Is this columns from a single table, or derived? I hope you don't have a table where ALL columns could be null (which would mean it doesn't have a primary key). More on reddit.com
🌐 r/SQLServer
23
4
September 26, 2024
sql - Find out column having null values - Stack Overflow
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 ... More on stackoverflow.com
🌐 stackoverflow.com
sql - How do I check if a column is empty or null in MySQL? - Stack Overflow
I have a column in a table which might contain null or empty values. How do I check if a column is empty or null in the rows present in a table? (e.g. null or '' or ' ' or ' ' and ...) More on stackoverflow.com
🌐 stackoverflow.com
🌐
W3Schools
w3schools.com › sql › sql_null_values.asp
SQL NULL Values - IS NULL and IS NOT NULL
SELECT column_names FROM table_name ... a selection from the Customers table used in the examples: The IS NULL operator is used to test for empty values (NULL values)....
🌐
LearnSQL.com
learnsql.com › cookbook › how-to-find-records-with-null-in-a-column
How to Find Records with NULL in a Column | LearnSQL.com
Use the IS NULL operator in a condition with WHERE to find records with NULL in a column. Of course, you can also use any expression instead of a name of a column and check if it returns NULL.
🌐
Mimo
mimo.org › glossary › sql › is-null
SQL IS NULL Condition: Syntax, Usage, and Examples
The SQL IS NULL condition helps you check if a column contains no value, meaning it's undefined or missing. In relational databases, NULL represents the absence of data, not zero or an empty string. Use SQL IS NULL in your WHERE clause to find rows where a specific column has a NULL value.
Top answer
1 of 4
5

Two Solutions (Column is All NULLs, Column Contains Some NULLs)

I have slightly altered your original example in order to provide two solutions:

Column_1 Column_2 Column_3
-------- -------- --------
1        2        NULL
1        NULL     NULL
5        6        NULL

First, test for NULLs and count them:

select 
    sum(case when Column_1 is null then 1 else 0 end) as Column_1, 
    sum(case when Column_2 is null then 1 else 0 end) as Column_2, 
    sum(case when Column_3 is null then 1 else 0 end) as Column_3,
from TestTable 

Yields a count of NULLs:

Column_1  Column_2  Column_3
0         1         3

Where the result is 0, there are no NULLs.

Second, let's count the non-NULLs:

select 
    sum(case when Column_1 is null then 0 else 1 end) as Column_1, 
    sum(case when Column_2 is null then 0 else 1 end) as Column_2, 
    sum(case when Column_3 is null then 0 else 1 end) as Column_3,
from TestTable

...But because we're counting non-NULLs here, this can be simplified to:

select 
    count(Column_1) as Column_1, 
    count(Column_2) as Column_2, 
    count(Column_3) as Column_3,
from TestTable

Either one yields:

Column_1  Column_2  Column_3
3         2         0

Where the result is 0, the column is entirely made up of NULLs.

If you only need to check a given column, then TOP 1 is quicker because it should stop at the first hit:

select count(*) from (select top 1 'There is at least one NULL' AS note from TestTable where Column_3 is NULL) a

0 = There are no NULLs, 1 = There is at least one NULL

SELECT COUNT(*) FROM (SELECT TOP 1 'There is at least one non-NULL' AS note FROM sat_data_active_season_group WHERE season_group IS NOT NULL) a

0 = They are all NULL, 1 = There is at least one non-NULL

I hope this helps.

2 of 4
3

we can check with the help of IN like

...WHERE NULL IN (Column_2, Column_3)

from your comment Well the multiple column will be Column_3, Column_2 in format might be this is helpful for you

select * from (select Column_3, Column_2 from @temp where null in (Column_3, Column_2)) as Result
🌐
Reddit
reddit.com › r/sqlserver › counting rows where all columns are either null or empty in the row?
r/SQLServer on Reddit: Counting rows where ALL columns are either null or empty in the row?
September 26, 2024 -

I'd rather not write a bunch of AND clauses, so is there a quick, efficient way to do this?

I'm importing some data with 10 fields into a SQL Server from a CSV file. Occasionally this file has null/empty values across all the cells/columns.

What I'd like to do is just write one relatively short sql statement to simply count (at first) all these rows. I'd rather do it without doing something like:

...and (column1 is null or column1 = '')
...and (column2 is null or column2 = '')

etc...

Is there a good way to do this, or am I stuck with the above?

🌐
Darling Data
erikdarling.com › home › blog › the right way to check for nulls in sql server queries
The Right Way To Check For NULLs In SQL Server Queries | Darling Data
May 16, 2022 - Not many databases have stuff going back to 1900, but I do see people using that as a canary value often enough. If that’s not enough to get you off the idea, let’s look at how this stuff plays out in the real world. First, let’s get ourselves an index. Without that, there’s fundamentally no difference in performance. ... SELECT c = COUNT_BIG(*) FROM dbo.Votes AS v WHERE v.BountyAmount IS NULL; SELECT c = COUNT_BIG(*) FROM dbo.Votes AS v WHERE v.BountyAmount IS NOT NULL;
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › sql server › how-to-check-a-column-is-empty-or-null-in-sql-server
How to Check a Column is Empty or Null in SQL Server - GeeksforGeeks
January 31, 2024 - ... The function NOT ISNULL() is just the opposite of ISNULL() Function explained above and returns all records without NULL, Empty, and Spaces in a particular column specified. ... The above select statement with 'NOT ISNULL()' returns all ...
🌐
Quora
quora.com › How-can-you-tell-if-a-database-has-null-values-using-SQL-queries
How to tell if a database has null values using SQL queries - Quora
Answer: SQL supports the ISNULL function. It can be applied to the columns in your table as part of a simple query. SELECT COUNT(*) FROM table WHERE column IS NULL This basic syntax can be modified to determine if there are any nulls in any column in a table using NOT and AND or OR.
🌐
Baeldung
baeldung.com › home › sql queries › find null or empty values in sql
Find Null or Empty Values in SQL Baeldung on SQL
August 5, 2026 - MS SQL provides a function ISNULL to check for null values: SELECT id, name FROM Department WHERE ISNULL(code, '') = '' OR TRIM(code) = ''; The ISNULL function in MS SQL takes two arguments: the first is a value or column name, and the second ...
🌐
Stack Overflow
stackoverflow.com › questions › 76163829 › find-out-column-having-null-values
sql - Find out column having null values - Stack Overflow
DECLARE @col_name VARCHAR(50) DECLARE @table_name VARCHAR(50) DECLARE @schema_name VARCHAR(50) DECLARE @sql VARCHAR(500) SET @table_name ='yourtable' SET @schema_name ='yourschema' DECLARE columns CURSOR FOR select COLUMN_NAME from INFORMATION_SCHEMA.columns where TABLE_NAME =@table_name and TABLE_SCHEMA =@schema_name OPEN columns FETCH NEXT FROM columns INTO @col_name WHILE @@FETCH_STATUS = 0 BEGIN set @sql = 'if exists(SELECT * from '+@schema_name+'.'+@table_name+' where '+@col_name+' is null) select '''+@col_name+''' ' exec (@sql) FETCH NEXT FROM columns INTO @col_name END CLOSE columns DEALLOCATE columns
🌐
Quora
quora.com › Is-it-possible-to-find-null-values-in-an-SQL-table-without-knowing-the-column-name
Is it possible to find null values in an SQL table without knowing the column name? - Quora
Answer (1 of 4): No - there is no SQL syntax for querying column values or NULL state in a table without knowing the column names. If you don’t know which columns contain NULLs, you can simply enumerate them, ie select * from mytable where col1 is null or col2 is null or … or colN is null; ...
🌐
W3Schools
w3schools.com › mysql › mysql_null_values.asp
MySQL NULL Values - IS NULL and IS NOT NULL
It is not possible to test for NULL values with comparison operators, such as =, <, or <>. We will have to use the IS NULL and IS NOT NULL operators instead. SELECT column_names FROM table_name WHERE column_name IS NULL;
🌐
Reddit
reddit.com › r/sql › check if an row has null columns
r/SQL on Reddit: Check if an row has null columns
July 20, 2021 -

Hello, I’m trying to do a system where I need to check if an given row has any value that is null. But the thing is, I don’t actually need to ensure not all columns are null, but rather an subset of them. And that subset is different based on user input.

For example I have

Column 1, column 2 , Column 3, column 4.

Sometimes I’d want to check if column 1,2 and 4 are not null, and sometimes I’d want to check if columns 1 and 4 aren’t null. Etc, it could be any subset of 1,2,3,4.

I thought that I could just load it in python and check for the dict keys, but I wanted to do it in a pure MySql way.