Infor LN SQL Query Generator for Oracle and SQL Server
Infor LN and Baan keep each company's data in physical tables named from the package, module, table number and company. This generator builds that name for you and gives you safe, read-only SQL for the common checks.
Fill in
The schema that owns the LN tables in your database. Check with your DBA.
Logical table name without the leading t and without the company number.
Three digit LN company number appended to the physical table name.
Column used to join header to lines and to filter.
Filtered select on the header table
SELECT * FROM baandb.ttdsls400100 WHERE t_orno BETWEEN 100000 AND 100999 ORDER BY t_orno;
Header joined to lines
SELECT h.t_orno, l.* FROM baandb.ttdsls400100 h JOIN baandb.ttdsls401100 l ON l.t_orno = h.t_orno WHERE h.t_orno BETWEEN 100000 AND 100999 ORDER BY h.t_orno;
Row counts for reconciliation
SELECT COUNT(*) AS header_rows FROM baandb.ttdsls400100; SELECT COUNT(*) AS line_rows FROM baandb.ttdsls401100;
Lines without a header (orphan check)
SELECT l.t_orno FROM baandb.ttdsls401100 l LEFT JOIN baandb.ttdsls400100 h ON h.t_orno = l.t_orno WHERE h.t_orno IS NULL;
Use read-only database accounts and run heavy queries on a replica or off hours. Column names beginning t_ and the table naming pattern t + package + module + number + company are standard in LN, but confirm column names for your table in the data dictionary. Item codes are often stored with leading blanks, so use TRIM when comparing. Never write to LN tables with SQL: use sessions, DAL or the supported APIs.
Ask LN questions without writing SQL
An optional walkthrough of a read-only, role-aware question layer over your LN data.
Optional. The tool and every export work without this. No spam.
How to use the generator
Enter the schema that owns the LN tables, the logical table names for header and lines, your company number and the key range you care about. The four blocks update live: a filtered select, a header to line join, row counts and an orphan check. Copy the block you need into your SQL client, or export the whole set. Always start with a narrow key range, because LN tables can hold millions of rows and an unfiltered join will punish a shared database.
How LN physical table names work
A logical table such as tdsls400 belongs to package td, module sls, table number 400. In the database it becomes t, then the logical name, then the three digit company number, for example ttdsls400100. Columns follow the pattern t_ plus the field name, such as t_orno for the order number. Because the company number is part of the table name, the same query pattern runs against any company by changing one field.
- Logical name: package (2 letters), module (3 letters), table number (3 digits)
- Physical name: t + logical name + company number
- Column name: t_ + field name
- Check the data dictionary for exact columns before relying on them
Reading the results
Header and line counts should be in a sensible ratio for your business, and the orphan check should return no rows. Orphans usually point to a failed conversion load or a partially deleted record. Compare counts before and after a migration load, and keep the numbers in your cutover log. If a join returns far more rows than expected, a key is probably not unique on its own and needs a second column, for example a position number.
Common mistakes
The most common errors are querying the wrong company number, forgetting that item codes carry leading blanks, and running reports against the production database in office hours. A second trap is trusting SQL to show business meaning: enumerated fields are stored as numbers, and the text lives in the domain definition. Use SQL for data checks and reconciliation, and use LN sessions or DAL for anything that changes data.
Frequently Asked Questions
Can I use these queries on both Oracle and SQL Server?
The statements use standard SQL: SELECT, JOIN, BETWEEN and COUNT. They run on both databases once you set the right schema or owner. If your LN installation uses a different database, check identifier quoting and schema rules with your DBA before running them.
Is it safe to write to LN tables with SQL?
No. Direct updates bypass DAL checks, audit trails and referential logic, and can corrupt data in ways that sessions cannot repair. Use read-only SQL for analysis and use sessions, exchange schemes or supported APIs for any change.
Why does my item filter return nothing?
Item codes in LN are often stored with leading blanks to fill the segment width. A plain equality test on the visible code misses them. Apply TRIM to the column or match with the padded value, and verify with a known item first.
How do I find the right table name?
Open the session in LN, use the about or table information option to see the tables it uses, or search the data dictionary by field name. Then plug the logical name into this generator.
If your team writes the same LN queries every week, we can put a governed question layer over the data so people ask in plain language and see the SQL it ran.
Related Tools
Infor LN and Baan Terminology Reference
A searchable glossary of Baan and Infor LN concepts for people joining a team or reading old documentation.
Infor LN & BaanInfor LN Integration Methods Reference
A comparison table of the main ways to move data in and out of Infor LN, with typical use, direction and cautions.
Infor LN & BaanInfor LN Cutover and Go-Live Checklist
A cutover checklist for Infor LN and Baan migrations: freeze, conversion, reconciliation, integrations, support and rollback decisions.
Infor LN & BaanInfor LN User Access Review Checklist
A practical checklist for periodic review of who can do what in Infor LN, covering roles, privileged access and segregation of duties.
More Infor LN & Baan tools
See all- Infor LN Session and Module Code Reference
- Infor LN Production Order Status and Lifecycle Reference
- Infor LN 4GL Session Script Template
- Infor LN Company and Enterprise Unit Design Worksheet
- Infor LN DAL Hook Review Checklist
- Infor LN Warehousing Order Origins and Types Reference
- Infor LN Table Name and SQL Query Builder
- Infor LN Regression Test Effort Calculator
- Infor LN and Baan Customization Inventory Worksheet
New to Infor LN and Baan? Start with the Infor LN and Baan guide and toolkit, or plan with Training Path Builder, Upgrade Path Planner, ERP Table and Field Explorer.
Keep exploring
Free tools
- Infor LN Table Name and SQL Query BuilderTurn an LN logical table such as tcibd001 into the physical SQL table name with company suffix and a ready SELECT statement.
- Infor LN Private AI Layer Blueprint GeneratorFill in your Infor LN environment and get a ready-to-share architecture plan for a private, on-prem AI assistant.
- Infor LN New Company Creation ChecklistStep-by-step checklist for adding a company to an on-prem Infor LN 10.x system, from planning the company number and table sharing to validating the first transactions.
ERP fixes and how-tos
- Infor LN Text Table: How Text Fields Are StoredHow Infor LN stores text fields in the text table (tttxt010), how to read it with SQL, and how to copy text between records or companies safely.
- How to diagnose and fix a slow Infor LN sessionDiagnose a slow Infor LN session by isolating whether the delay is in the database, the application tier or custom logic, then apply the matching fix.