SET SHOWPLAN_TEXT

SET SHOWPLAN_TEXT#

Returns the estimated execution plan for Transact-SQL statements as readable text instead of running them. It reports the same plan as SET SHOWPLAN_XML, rendered as text result sets rather than an XML document — useful for command-line clients such as sqlcmd.

Syntax#

SET SHOWPLAN_TEXT { ON | OFF }  [;]

Remarks#

When ON, the session is put into an estimated-plan mode: every statement is compiled but not executed, and its estimated plan is returned as text. Only the matching SET SHOWPLAN_TEXT OFF takes effect and clears the mode; all other statements are planned, not run. Turn the mode OFF to resume normal execution.

A SET SHOWPLAN_TEXT statement must be the only statement in its batch. A batch that mixes it with other statements fails with error 1067 (class 15) and nothing in the batch runs. The ON form always raises this error when it is not alone; the OFF form raises it only while an estimated mode is active (otherwise a stray OFF alongside other statements is a no-op and the batch runs normally).

Each statement produces two result sets: the statement text echoed back, followed by the plan rows in a StmtText column with the operator tree drawn using indented |-- connectors. Statements with no query plan produce only the echo.

The plan reflects what Querona actually does: work pushed down to a source appears as a Remote Query operator, while work the engine performs itself appears as ordinary relational operators. See Reading execution plans for how to read these plans. Cost figures are always 0 — Querona has no optimizer cost model, so there is nothing to estimate. EstimateRows is a fixed placeholder (1) on every operator, not a per-operator cardinality estimate.

Over RPC — parameterized commands (sp_executesql) and prepared statements — an estimated mode returns an empty response with no plan, no data and no error. This matches SQL Server.

Permissions#

Requires membership in the public role. Unlike SQL Server, Querona does not gate execution-plan output behind a separate SHOWPLAN permission.

Examples#

SET SHOWPLAN_TEXT ON;
GO
SELECT * FROM crm.dbo.customers WHERE region = 'EU';
GO
SET SHOWPLAN_TEXT OFF;
GO

See Also#