Index / Guide
Using ChatGPT or Claude to Write HaloPSA SQL Reports (copy-paste prompt)
AI assistants are good at SQL but bad at HaloPSA, because they don't know its schema and they don't know Halo's quirks. Out of the box they invent column names and write queries Halo rejects. Paste this in first and the results get usable straight away.
The prompt
You are writing read-only T-SQL for a HaloPSA custom SQL report (Microsoft SQL Server). Schema (legacy NetHelpDesk names): - FAULTS = tickets (also projects, opportunities and tasks). Key columns: Faultid, Symptom (summary), dateoccured (created), datecleared (resolved), Status -> TSTATUS.Tstatus, Areaint -> AREA.Aarea, Assignedtoint -> UNAME.Unum, Requesttype -> REQUESTTYPE.RTid, urgency, impact, fixbydate, FResponseDate, FRespondByDate, Flastactiondate, FDeleted, FexcludefromSLA, InvoiceDate - ACTIONS = notes, emails and time entries. Join on Faultid. timetaken, ActionChargeHours, ActionNonChargeHours are decimal hours. Charge value is ActionChargeAmount (NOT AChargeTotalAction, which is a bit flag) - AREA = clients (aareadesc = name). UNAME = agents (uname = name). SITE = sites. USERS = end users - REQUESTTYPE has RTIsOpportunity and RTIsProject flags Rules Halo enforces: 1. Always start with SELECT TOP n (ORDER BY fails otherwise, Halo wraps the query as a subquery) 2. No trailing semicolon 3. No -- comments. Use /* */ or none 4. Exclude soft-deleted rows: ISNULL(FDeleted,0) = 0 5. For ticket-only reports join REQUESTTYPE and filter ISNULL(RTIsOpportunity,0) = 0 AND ISNULL(RTIsProject,0) = 0 6. There is no priority column and no SLA breach flag. Breach = datecleared > fixbydate 7. Prefer derived-table JOINs over correlated subqueries in the SELECT list If you are unsure a column exists, ask me to run: SELECT TOP 10000 TABLE_NAME, COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'FAULTS' Now write this report: [describe what you want]
Tips
- Ask for one report at a time and paste Halo's error back in if it fails. Most errors are one of the rules above.
- Test on a small date range first. AI-written joins on ACTIONS can multiply rows if they forget to group.
- Check the numbers against a ticket you know before trusting a report in a QBR.
Prefer reports that are already written and tested? See the schema guide and the free reports below.