Quickbooks File Repair — "No primary key value for foreign key"
"No primary key value for foreign key" is a Sybase database error that appears when QuickBooks tries to rebuild or reload its internal data file and finds a child record pointing to a parent record that no longer exists. It is a direct signal of structural corruption inside the company file's database.
What this error means
QuickBooks stores its data in a Sybase SQL Anywhere database. Tables are linked by foreign keys -- a child row references a parent row's primary key. When the reload process hits a foreign key whose matching primary key is missing, it cannot complete the relationship and logs an error such as:
No primary key value for foreign key 'fkey_target_id' in table 'es_paycheck_header'No primary key value for foreign key 'fkey_transaction_id' in table 'es_paycheck_lineitem'
The accompanying SQLCODE=-194 and ODBC state 23000 confirm a referential-integrity violation in the underlying database, typically encountered while running reload.sql during a rebuild.
Common causes
- Orphaned payroll or transaction line-item records whose parent header was lost.
- An interrupted rebuild, crash, or improper shutdown that left the database half-written.
- Disk, network, or hardware faults that damaged specific table pages.
Why the built-in tools often can't fix this
Verify and Rebuild operate at the QuickBooks transaction level, but this error lives deeper, in the database engine's reload step. When the rebuild itself throws "No primary key value for foreign key," the tool that is supposed to repair the file is the one reporting the corruption -- so re-running it usually reproduces the same failure rather than resolving it.
When professional recovery is the safer path
Errors at this layer call for database-level work: locating the orphaned child rows, reconstructing or safely removing the broken references, and rebuilding the table relationships so the file reloads cleanly. Our engineers work directly inside the company-file database to repair these foreign-key violations while preserving your transactions, payroll history, and lists.
If your rebuild halts on a foreign-key error, our QuickBooks data recovery team can help. You can start a recovery with no risk -- no data recovered, no charge, and all work performed in-house in North America.