Run raw SQL query (read-only)
run_queryRun read-only SQL queries on SQL Server with full SELECT support—CTEs, subqueries, aggregates, window functions. Ensures safety by automatically rolling back and limiting results to 500 rows.
Instructions
Run an arbitrary read-only query — CTEs (WITH ...), subqueries, GROUP BY/aggregates, window functions, UNION, ORDER BY, anything a single SELECT statement can express. Only one SELECT (optionally led by a WITH clause) statement is allowed: the query is rejected before it reaches the database if it contains a second statement or any write/DDL/EXEC keyword, and it additionally always runs inside a transaction that gets rolled back afterwards regardless of outcome, as a second line of defense. Results are capped at 500 rows.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | A single SELECT statement, optionally starting with a WITH ... CTE |