Query a table or view
query_tableRuns read-only SELECT queries on a table or view with filters, ordering, grouping, aggregates, pagination and sampling. Returns rows with row_count and a truncated flag so partial results are never mistaken for complete ones.
Instructions
Runs a SELECT on one table or view, with optional column list, filter, ordering, grouping, aggregates (COUNT, SUM, AVG, MIN, MAX), pagination and random sampling, and returns the rows in an object with row_count and a measured 'truncated' flag, so a short result is never mistaken for a complete one. Rows are capped by the database's max_query_rows. Call get_table_schema first for exact column names; for null ratios, distinct counts and frequent values use get_data_profile instead of paging through rows. Reads actual data; never runs INSERT, UPDATE, DELETE or procedures.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"database": "<database>",
"table": "<table>"
},
"name": "query_table"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| top | No | Maximum number of rows to return (default 100, capped by the per-database limit). | |
| skip | No | Number of rows to skip before returning results (for pagination, default 0). | |
| table | Yes | Table or view name, bare, with no schema prefix. Example: 'GenericSecurity' | |
| where | No | WHERE clause without the WHERE keyword: one boolean expression, which may call functions and hold subqueries. Comments, ';', a second statement, tables on a linked server and system functions that read server files are refused. Example: "Source = 'BDS' AND ReferenceDate >= '2026-01-01'" | |
| schema | No | Table/view schema. Empty means dbo. Example: 'Feeder' | |
| columns | No | Columns as ONE comma-separated string, not a JSON array. Example: 'ReferenceDate, Source, Close'. Empty or '*' returns every column. Reserved words need no quoting or brackets. | |
| database | Yes | Name of the database as registered in the configuration. | |
| group_by | No | GROUP BY columns as ONE comma-separated string. Example: 'Source, Name' | |
| order_by | No | ORDER BY list without the ORDER BY keywords: columns or expressions separated by commas, each optionally followed by ASC or DESC. Example: 'ReferenceDate DESC, Name' | |
| aggregates | No | Aggregates as ONE comma-separated string of FUNC(column) [AS alias], with FUNC one of COUNT, SUM, AVG, MIN, MAX. Only a bare column name is allowed inside the parentheses. Example: 'COUNT(*) AS Total, MAX(ReferenceDate) AS Ultima' | |
| sample_percent | No | Random sampling percentage, from 0.01 to 100. Zero (the default) means no sampling. |