Run a read-only SQL query
queryRun a read-only SQL statement against the Autotask Report Data Warehouse to get structured columns and rows for finance, contracts, projects, time, and tickets reporting.
Instructions
Execute EXACTLY ONE read-only SQL statement against the Autotask Report Data Warehouse and return its columns and rows (structuredContent plus a compact text table). The statement MUST be a single SELECT or WITH (CTE) query. The read-only guard REJECTS everything else: INSERT, UPDATE, DELETE, MERGE, DROP, ALTER, CREATE, TRUNCATE, EXEC/EXECUTE, GRANT, REVOKE, SELECT ... INTO, stored/extended procedures (sp_/xp_), and any second statement (a statement-separating semicolon). Rows are hard-capped by max_rows (ceiling 500). READ the resource warehouse://guide before writing queries - this warehouse uses non-obvious names. Key traps: there is NO wh_ticket / wh_time_entry / wh_ticket_note view; tickets AND project tasks share wh_task, where a ticket has project_id IS NULL and a project task has project_id IS NOT NULL; join hours as wh_time_item.time_item_id = wh_time_subitem.time_item_id (task_id lives only on wh_time_item); money columns (wh_posted_overall, wh_billing_item) come back as decimal strings. Almost every *_id column is a foreign key: resolve the IDs that matter to human-readable names by JOINing the matching lookup view (see the 'ID RESOLUTION' map in warehouse://guide) and return names, not raw IDs, unless the user explicitly asks for IDs. If the result comes back with truncated=true it is INCOMPLETE (more rows matched than the cap) - narrow with WHERE/GROUP BY, aggregate, or raise max_rows; do not treat the returned count as the total. Data freshness: the warehouse is a DAILY full snapshot, not a live system - values can be up to a day old; for time-critical questions call last_load and state the load time, or use the live Autotask source instead of presenting a stale figure as current. For business terms (revenue, cost, margin, open ticket, billed/worked hours, utilization, active contract/employee) use the canonical definition from the BUSINESS GLOSSARY in warehouse://guide instead of interpreting them freely, and state the definition and time window you used.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | One read-only SELECT or WITH statement. Example: "SELECT TOP 10 account_id, account_name FROM wh_account WHERE is_active = 1". Tickets example: "SELECT TOP 20 task_number, account_id, task_status_id FROM wh_task WHERE project_id IS NULL". No writes, no second statement. | |
| max_rows | No | Maximum rows to return; capped at the server ceiling MSSQL_MAX_ROWS (500). Example: 25. Omit to use the ceiling. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rows | Yes | ||
| columns | Yes | ||
| row_cap | Yes | The cap applied to this query (min of max_rows and the server ceiling). | |
| truncated | Yes | True if more rows matched than were returned; the result is incomplete. | |
| returned_rows | Yes | Number of rows actually returned (after the cap). | |
| any_cell_truncated | Yes |