SOQL Query to Find Products With a Blank ProductCode
Find products with an empty ProductCode using SOQL, including the NULL syntax, blank-string gotcha, and a count-first workflow.
Updated 2026-09-09
Blank required-in-practice fields are the quiet tax on every report. This query lists the products where ProductCode was never filled in.
The product object is named Product2 in the API even though the UI calls it Product, which trips up most first-time SOQL queries.
The query
In SOQL, NULL is a keyword - it is never quoted and never compared with IS NULL.
SELECT Id, Name, ProductCode, Family
FROM Product2
WHERE ProductCode = NULL
ORDER BY CreatedDate DESC
LIMIT 200Count first, then export
Before exporting, size the problem. If the count is in the hundreds it is a cleanup task; if it is in the tens of thousands it is a process problem upstream.
SELECT COUNT()
FROM Product2
WHERE ProductCode = NULLText fields can be blank without being NULL
An imported empty string is not the same as a null value in every context. For text fields, check both to be safe.
SELECT Id, Name, ProductCode, Family
FROM Product2
WHERE ProductCode = NULL OR ProductCode = ''Common mistakes to avoid
- Use the API name
Product2, not the UI label - the two differ on several standard objects. - Wrap literal text values in single quotes; date literals such as
LAST_N_DAYS:30must stay unquoted. - Run the query in a sandbox first if it feeds a bulk update - a
WHEREclause that is one character off can select the whole table. != NULLis the correct way to ask for populated values; there is noIS NOT NULLin SOQL.- Formula and roll-up fields cannot always be filtered on - if the query errors, the field is not filterable.
Run it faster with TurboKit
Finding the blanks is easy; fixing them means exporting, editing, and re-importing the same rows.
TurboKit's AI SOQL builder lets you describe the result you want in plain English, returns the query, and exports the rows to CSV or Excel in the same panel - without leaving the Salesforce tab you are already on.
Frequently asked questions
- Does SOQL support IS NULL?
- No. SOQL uses
= NULLand!= NULL.IS NULLis SQL syntax and returns a malformed-query error in Salesforce. - Can I filter Product2 on a blank picklist?
- Yes - an unset picklist compares equal to
NULL. A picklist set to a value that was later removed from the value set is still a non-null string, so it will not appear. - Why do some fields error when I filter on NULL?
- Non-filterable fields - long text areas, some formula fields, and encrypted fields - cannot appear in a
WHEREclause at all.
More from the SOQL Library
- SOQL Query to Find Duplicate Products by ProductCodeFind duplicate products in Salesforce with a GROUP BY / HAVING SOQL query on ProductCode, then pull the underlying record IDs.
- SOQL Query to Find Accounts With a Blank IndustryFind accounts with an empty Industry using SOQL, including the NULL syntax, blank-string gotcha, and a count-first workflow.
- SOQL Query to Find Cases With a Blank ContactIdFind cases with an empty ContactId using SOQL, including the NULL syntax, blank-string gotcha, and a count-first workflow.
- SOQL Query to Find Contacts With a Blank EmailFind contacts with an empty Email using SOQL, including the NULL syntax, blank-string gotcha, and a count-first workflow.
- SOQL Query to Find Duplicate Accounts by NameFind duplicate accounts in Salesforce with a GROUP BY / HAVING SOQL query on Name, then pull the underlying record IDs.
- SOQL Query to Find Duplicate Contacts by EmailFind duplicate contacts in Salesforce with a GROUP BY / HAVING SOQL query on Email, then pull the underlying record IDs.
Related reading
- Admin How-ToHow to Find and Merge Duplicate Records in SalesforceA full workflow for cleaning up duplicate accounts, contacts, and leads in Salesforce - the native merge tool, its record limits, and the SOQL to find what it can't show you.
- Admin How-ToHow to Write Salesforce Queries Without Knowing SOQL (AI SOQL)Describe the records you want in plain English and get a runnable SOQL query back - how AI SOQL builders work, what to check before you run the result, and where they still fall short.
- GlossaryWhat Is a Duplicate Rule in Salesforce?A duplicate rule defines what Salesforce does when a user is about to save a record that looks like an existing one - block it, allow it with a warning, or ju
- GlossaryWhat Is an AI SOQL Builder in Salesforce?An AI SOQL builder turns a plain-English description of the records you want into a runnable SOQL query, using the schema of the org you are working in so the