Read Data from SQL Server
read_dataExecute read-only SELECT or WITH queries against a named SQL Server instance; small results return inline JSON, large results write to CSV for code processing.
Instructions
Execute a read-only SQL SELECT query against a named SQL Server instance. Only SELECT and WITH (CTE) queries are allowed. Use list_servers first to discover available server names. Small results are returned inline as JSON {truncated, rows}. Large results (over the configured row threshold, 500 by default, or about 40,000 characters) are written to a CSV file instead, and the response gives the file path, row count, column names and types, and a 10-row preview. Process a result file with code (e.g. Python csv/pandas, PowerShell Import-Csv) rather than reading it into context.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | SQL SELECT query to execute. Only SELECT and WITH (CTE) queries are permitted. | |
| toFile | No | Write the full result to a CSV file and return its path and a preview, whatever its size. Use when the rows will be processed with code. | |
| serverName | Yes | Name of the SQL Server to query (use list_servers to see available names) | |
| databaseName | Yes | Name of the database to query (use list_databases to see available databases) |