Run SELECT Query
mssql_run_selectRun one read-only SELECT or WITH query for ad-hoc DBA analysis of system views and DMVs; writes are rejected and results are capped at 500 rows. Use databaseName to query another database.
Instructions
Run one read-only SELECT (or WITH ... SELECT) query: ad-hoc analysis of system views and DMVs when no other tool fits. One statement only; INSERT, UPDATE, EXEC, SET, USE, SELECT INTO and anything else that writes or changes the session are rejected. Use databaseName instead of USE to run in another database. Returns at most 500 rows; add TOP, WHERE or GROUP BY to narrow.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selectQuery | Yes | One read-only SELECT statement, for example: SELECT TOP (10) name, create_date FROM sys.tables ORDER BY create_date DESC | |
| databaseName | No | Database to run the query in. Defaults to the connected database (DB_NAME). |