Postman collection
Customers Read

pixiEmillGetCustomers

Returns customers with email address and name, optionally filtered by order or ship date, item, payment and shipping status or shop, with key-based paging.

Returns a list of customers (key, email, first name, last name, shop) for use in email marketing tools. The procedure builds a dynamic query on Customers joined to Addresses (inner join on the customer's address reference). All filters are optional and combined with AND:

  • orderdate: only customers with at least one order line whose order date falls on the same calendar day (year, month and day are compared; the time is ignored).
  • ShipDate: only customers with at least one order line shipped on that calendar day.
  • EanUpc: only customers who ordered an item with this EAN/UPC.
  • ArticleNr: only customers who ordered an item whose supplier item number (ItemNrSuppl) matches.
  • paid: 1 = customers with at least one invoice where the paid sum equals the total; 0 = customers with at least one invoice where the paid sum differs from the total.
  • Shipped: 1 = customers with at least one shipped order line; 0 = customers with at least one order line without ship date.
  • ShopID: only customers belonging to this shop (CustomerOf). An empty string is treated as no filter.

The result is sorted by customer key ascending and limited to Top rows. For paging, pass the highest custkey of the previous page as resumeKey; only customers with a larger key are returned.

Notes

  • All reads use NOLOCK, so results can contain uncommitted data.
  • The row limit is applied with SET ROWCOUNT; Top = 0 returns all matching rows.
  • Customers without a matching address record are not returned because of the inner join.
  • The paid and Shipped filters test for at least one matching invoice or order line, not for all of them. paid = 1 therefore also returns customers who additionally have unpaid invoices.
  • Date filters use DATEPART on the column, so indexes on order or ship date cannot be used; on large databases these filters can be slow.
  • ArticleNr is compared with the supplier item number (ItemNrSuppl), not with the internal item number.
  • The statement is passed to sp_executesql under the parameter name @statment instead of the documented @stmt; the call relies on positional handling of this parameter.

Tables used

Customers · Read Addresses · Read Orderlines · Read Items · Read Invoices · Read
SQL object:
dbo.pipiEmillGetCustomers
Updated at 2026-10-30