Save e-invoices to a SQL Server database automatically

Save e-invoices to a SQL Server database automatically

If you want to analyze invoice data, show it in dashboards or hand it over to follow-up systems, you need it in a database. This how-to shows how Automatic X-Invoice Processor automatically writes the data of every incoming e-invoice into a Microsoft SQL Server table - optionally with an additional table for the invoice line items and with built-in duplicate protection.

At a Glance

  • Difficulty: Advanced
  • Time required: about 15 minutes
  • Prerequisites: Automatic X-Invoice Processor installed; a reachable Microsoft SQL Server with credentials and write permissions
  • Task used: Save to database

Step 1: Set up the database connection

Connections are managed centrally in the program options - profiles only reference the connection name; the credentials stay on this computer and do not travel with profile exports.

  1. Open Menu → Options…, page Database connections.
  2. Click Add… and enter server, authentication and credentials.
Program options, Database connections page

Note: Since the credentials stay local, a connection with the same name must be set up on every workstation that runs the database task (see chapter 40.14).


Step 2: Create a profile

  1. Click New profile… in the profile toolbar and enter a name (e.g. “Invoices to database”).
  2. Under Mode, choose the file type of your invoices and add the inbox folder under Monitored folders.
  3. Add a typical invoice under Example invoices.

The basic setup is described in detail in the how-to “Getting started”.


Step 3: Configure the “Save to database” task

Click Add in the task list and choose Save to database.

Save to database task with the Database, Fields and Options tabs

On the Database tab:

  1. Choose the connection from step 1 (New connection… leads directly to the program options).
  2. Choose the database on the server.
  3. Choose the target table - or click Create new…: the program creates a new table with the selected fields as columns.

Step 4: Select the fields

On the Fields tab you choose which invoice fields are stored as columns. The catalog is grouped by topic (invoice data, seller, buyer, amounts, payment, …).

Fields tab of the database task with the grouped field catalog

The fields marked with * - invoice number, invoice date and seller - form the duplicate key and are always active.


Step 5: Duplicate behavior and line items

On the Options tab:

  • If an entry already exists (same invoice number, same invoice date, same seller): Overwrite entry or Skip (do not save again). This keeps the table free of duplicates even when the same invoice is processed again - e.g. after a Catch up… run.
  • Additionally save invoice line items to a separate table: Writes one row per invoice line item into the configured line item table, linked to the invoice entry - for analyses on article level.

Step 6: Verify and save

  1. Check the configuration in the result preview (see chapter 8.11).
  2. Click OK and place an invoice into the monitored folder - or click Check now in the status bar.
  3. Then verify via a SQL query (e.g. in SQL Server Management Studio) that the record has arrived.

Good to know

  • Combine the task with Move file to archive processed invoices afterwards - the order of the task list is the execution order.
  • If the database access fails (server unreachable, missing permissions), an error entry is created in the processing log; after fixing the issue, simply use Process file again in the context menu.
  • For simple analyses without a database, the CSV task Save extract as CSV is often sufficient (see chapter 11).

Common issues

Issue Solution
Connection fails Check server name/instance, firewall and authentication type; edit the credentials in the program options
A profile export on another computer does not find the connection Create a connection with the same name in the program options on the target computer
Invoices appear twice in your own queries Set the duplicate behavior to Skip; the duplicate key is invoice number + invoice date + seller

Further reading

Start your no-obligation, 30-day free trial of Automatic X-Invoice Processor now ...     Download