Developer ToolsFree generatorPDF, Excel, Word exportSage EvolutionSouth Africa

Sage Evolution SQL Query Generator for Stock and Debtors

Sage Evolution keeps stock, customers and documents in SQL Server tables that are easy to query for reports. This generator builds clean, read-only starting queries you can paste into SQL Server Management Studio.

Fill in

Generated code
Download:

Stock items

USE [EvolutionCompany];

SELECT TOP (200)
    s.StockLink,
    s.Code,
    s.Description_1
FROM dbo.StkItem AS s
WHERE s.Code LIKE 'BRK%'
ORDER BY s.Code;

Customer accounts

SELECT TOP (200)
    c.DCLink,
    c.Account,
    c.Name
FROM dbo.Client AS c
WHERE c.Account LIKE 'A%'
ORDER BY c.Account;

Invoice headers by customer

SELECT TOP (200)
    i.AutoIndex,
    i.InvNumber,
    c.Account,
    c.Name
FROM dbo.InvNum AS i
JOIN dbo.Client AS c ON c.DCLink = i.AccountID
WHERE c.Account LIKE 'A%'
ORDER BY i.AutoIndex DESC;

Run read-only and test on a copy of the company database first. Table and column names such as StkItem, Client and InvNum are common in Sage Evolution databases, but confirm them against your own version before using the results for decisions.

Read-only ERP query access

Optional: see how natural-language questions can produce reviewed SQL on your ERP.

Optional. The tool and every export work without this. No spam.

How to use the generator

Enter your company database name, the stock code and customer account prefixes you want to see, and a maximum row count. The generator fills three queries: a stock item list, a customer account list and a join of invoice headers to customers. Copy the output into your query tool and run it against a test copy first.

What the tables hold

StkItem holds stock item master records, Client holds customer accounts, and InvNum holds document headers such as invoices and orders. Joins are usually made on link columns such as DCLink and AccountID rather than on account codes, which is safer if codes change.

  • StkItem for stock codes and descriptions
  • Client for customer accounts
  • InvNum for document headers
  • Join on link keys, not display codes

Staying safe

Use a read-only SQL login for reporting and avoid long-running queries during invoicing hours. Never update Sage tables directly, because the application keeps balances and posting tables consistent. Use Sage's own import tools or SDK for writes.

Common mistakes

Typical errors include running queries against the wrong company database, using LIKE with a leading wildcard on large tables, and forgetting that deleted or inactive records may still appear in the table.

Frequently Asked Questions

Which Sage Evolution versions does this work with?

The table names are common across many Evolution releases, but they can differ between versions and customised installs. Check each table and column in your database before running the output in production reports.

Is it safe to run these queries?

They are SELECT statements only. Still, run them on a test copy or under a read-only login, because large queries can slow users who are posting transactions in the live company database.

Why join on DCLink instead of Account?

DCLink is the internal link key used between tables. Account codes can be edited by users, whereas link keys stay stable, so joins on link keys are more reliable for reports.

Can I add date filters?

Yes. Add a WHERE condition on the date column of the document table you use, and confirm the exact column name in your version. Always parameterise dates when you build reports in a tool.

If your team writes many one-off Sage queries, Netray can set up private natural-language access that shows the generated SQL and stays read-only.