QuickBooks Vendors SQL Template

SQL table creation template for syncing QuickBooks vendor (supplier) data to your PostgreSQL database.

Updated: 2 Feb 2026

QuickBooks Vendors SQL Template

Create a database table to store QuickBooks vendor data including contact information, payment details, and 1099 tracking for supplier management.

What Data is Synced?

The QuickBooks Vendors sync captures essential vendor/supplier information from your QuickBooks account:

  • Vendor ID: Unique QuickBooks vendor identifier
  • Company ID: QuickBooks company realm ID for multi-company support
  • Display Name: Primary vendor display name
  • Company & Personal Names: Company name, given name, and family name
  • Contact Info: Primary email address and phone number
  • Financial Details: Outstanding balance, account number, and currency
  • Status & Tax Info: Active status, 1099 vendor flag, and tax identifier
  • Complete Data: Full QuickBooks vendor object stored as JSONB
  • Sync Tracking: Timestamp of when CLS last synced this record

SQL Table Template

Table Schema Explanation

Here's what each column in the table represents:

ColumnTypeDescription
idTEXTQuickBooks vendor ID. Part of composite primary key.
company_idTEXTQuickBooks company ID (realm_id). Part of composite primary key.
display_nameTEXTPrimary display name for the vendor.
company_nameTEXTVendor's company/business name.
given_nameTEXTVendor contact's first name.
family_nameTEXTVendor contact's last name.
primary_email_addrTEXTVendor's primary email address.
primary_phoneTEXTVendor's primary phone number.
balanceNUMERICOutstanding balance owed to vendor.
activeBOOLEANWhether the vendor is active in QuickBooks.
vendor_1099BOOLEANWhether the vendor is eligible for 1099 reporting.
tax_identifierTEXTVendor's tax ID (SSN or EIN).
acct_numTEXTYour account number with this vendor.
currency_refTEXTVendor's default currency code.
dataJSONBComplete QuickBooks vendor object stored as JSON.
livemodeBOOLEANWhether this is production data.
createdTIMESTAMPTZTimestamp when vendor was created in QuickBooks.
updated_atTIMESTAMPTZTimestamp when vendor was last modified in QuickBooks.
synced_atTIMESTAMPTZTimestamp when CLS last synced this vendor record. Auto-updated.

The table uses a composite primary key (id, company_id) to support syncing vendors from multiple QuickBooks companies to the same table.

Usage Examples

After syncing, you can query your vendor data using standard SQL:

-- Get all active vendors
SELECT display_name, company_name, primary_email_addr
FROM quickbooks_vendors
WHERE active = true;

-- Find vendors eligible for 1099 reporting
SELECT display_name, tax_identifier, balance
FROM quickbooks_vendors
WHERE vendor_1099 = true AND active = true;

-- Calculate total outstanding payables by vendor
SELECT
  display_name,
  balance AS outstanding_balance
FROM quickbooks_vendors
WHERE balance > 0
ORDER BY balance DESC;

-- Search vendors by email domain
SELECT display_name, primary_email_addr
FROM quickbooks_vendors
WHERE primary_email_addr LIKE '%@example.com';

-- Get vendors for a specific company
SELECT * FROM quickbooks_vendors
WHERE company_id = 'your_realm_id'
ORDER BY display_name;

-- Find vendors without contact information
SELECT display_name, company_name
FROM quickbooks_vendors
WHERE primary_email_addr IS NULL
  AND primary_phone IS NULL;

-- Get vendors created in the last 30 days
SELECT * FROM quickbooks_vendors
WHERE created > NOW() - INTERVAL '30 days';

-- Query address from JSONB data
SELECT
  display_name,
  data->'BillAddr'->>'Line1' AS address_line1,
  data->'BillAddr'->>'City' AS city,
  data->'BillAddr'->>'PostalCode' AS postal_code
FROM quickbooks_vendors
WHERE data->'BillAddr' IS NOT NULL;

Common Customizations

The template includes performance indexes for company_id, display_name, email, active, and vendor_1099 columns. You can add additional table-specific customizations:

Add Index for Account Number Lookups

CREATE INDEX idx_quickbooks_vendors_acct_num
ON quickbooks_vendors(acct_num);

Add Index for Balance Queries

CREATE INDEX idx_quickbooks_vendors_balance
ON quickbooks_vendors(balance)
WHERE balance > 0;

Add Compound Index for 1099 Reporting

CREATE INDEX idx_quickbooks_vendors_1099_active
ON quickbooks_vendors(vendor_1099, active)
WHERE vendor_1099 = true;
  • Bills - Bill/payable records linked to vendors
  • Payments - Payment records
  • Customers - Customer records for comparison