Handling Leading Zeros in Product IDs and Part Numbers

2026-01-11By Cole Tenold3 min read
Data CleaningExcelIDs

Leading zeros cause problems. Excel drops them. Databases expect them. Here's how to handle them correctly.

The Problem

Your part numbers look like this in the system:

Part Number
00123456
00789012
00345678

Excel shows them as:

Part Number
123456
789012
345678

Now your SQL query returns zero results because 123456 doesn't match 00123456.

Solution 1: Fill Leading Zeros

If your IDs should be 8 digits, pad them:

Input:

ID
123456
789012
345678

Output (filled to 8 digits):

('00123456', '00789012', '00345678')

Set "Fill Leading Zeros" and specify the target length.

Solution 2: Trim Leading Zeros

If you need to match against a column that stores integers:

Input:

ID
00123456
00789012
00345678

Output:

(123456, 789012, 345678)

Use "Trim Leading Zeros" to strip them.

Trim Modes

Integer Only: Only trims if the value is purely numeric

InputOutput
00123123
00ABC00ABC (unchanged)

All: Trims leading zeros from any value

InputOutput
00123123
00ABCABC

Common Formats

Data TypeTypical LengthExample
UPC codes12 digits012345678901
ZIP codes5 digits01234
Part numbersVaries0000012345
Serial numbersVaries00000000001

SQL Query Example

After padding to 8 digits:

SELECT product_name, stock_level
FROM inventory
WHERE part_number IN ('00123456', '00789012', '00345678')

Database Column Types

VARCHAR/TEXT: Store as strings, leading zeros preserved

INT/BIGINT: Store as numbers, leading zeros dropped

Know your schema before querying. If the column is VARCHAR, you need the zeros. If it's INT, you don't.

Ready to transform your clipboard?

Try our free tool to clean, format, and convert your data instantly.