Paste this into a new question or an answer at dba.stackexchange.com:
<!-- --> > select * > into docs > from (values ('Enter one batch per field, don''t use ''GO''') > , ('Fields grow as you type') > , ('Use the [+] buttons to add more') > , ('See examples below for advanced usage') ) z(how_to_use_dbfiddle); > GO > > <pre> 4 rows affected > </pre> <!-- --> > select * from docs; > GO > > <pre> > | how_to_use_dbfiddle | > | :---------------------------------------- | > | Enter one batch per field, don't use 'GO' | > | Fields grow as you type | > | Use the [+] buttons to add more | > | See examples below for advanced usage | > </pre> <!-- --> > -------------------------------------------------------------------------------- > -- ① Execution Plans > -------------------------------------------------------------------------------- > set statistics profile on; > select max('Do this to get execution plans and stats') "Execution Plans" > from docs d1 cross join docs d2; > set statistics profile off; > GO > > <pre> > | Execution Plans | > | :--------------------------------------- | > | Do this to get execution plans and stats | > > Rows | Executes | StmtText | StmtId | NodeId | Parent | PhysicalOp | LogicalOp | Argument | DefinedValues | EstimateRows | EstimateIO | EstimateCPU | AvgRowSize | TotalSubtreeCost | OutputList | Warnings | Type | Parallel | EstimateExecutions > :--- | :------- | :---------------------------------------------------------------------------------------------------------- | -----: | -----: | -----: | :--------------- | :--------- | :---------------------------------------------------------------------- | :--------------------------------------------------------- | :----------- | :--------- | :---------- | ---------: | :--------------- | :--------- | :---------------- | :------- | :------- | :----------------- > 1 | 1 | select max('Do this to get execution plans and stats') &quot;Execution Plans&quot;&lt;br&gt;from docs d1 cross join docs d2 | 1 | 1 | 0 | <em>null</em> | <em>null</em> | <em>null</em> | <em>null</em> | 1 | <em>null</em> | <em>null</em> | <em>null</em> | 0.00689848 | <em>null</em> | <em>null</em> | SELECT | False | <em>null</em> > 1 | 1 | |--Stream Aggregate(DEFINE:([Expr1004]=MAX('Do this to get execution plans and stats'))) | 1 | 2 | 1 | Stream Aggregate | Aggregate | <em>null</em> | [Expr1004]=MAX('Do this to get execution plans and stats') | 1 | 0 | 1.01E-05 | 31 | 0.00689848 | [Expr1004] | <em>null</em> | PLAN_ROW | False | 1 > 16 | 1 | |--Nested Loops(Inner Join) | 1 | 3 | 2 | Nested Loops | Inner Join | <em>null</em> | <em>null</em> | 16 | 0 | 6.688E-05 | 9 | 0.00688838 | <em>null</em> | NO JOIN PREDICATE | PLAN_ROW | False | 1 > 4 | 1 | |--Table Scan(OBJECT:([fiddle_7ce3ca94f6e64aaf88f62c57ccca5fdf].[dbo].[docs] AS [d2])) | 1 | 4 | 3 | Table Scan | Table Scan | OBJECT:([fiddle_7ce3ca94f6e64aaf88f62c57ccca5fdf].[dbo].[docs] AS [d2]) | <em>null</em> | 4 | 0.003125 | 0.0001614 | 9 | 0.0032864 | <em>null</em> | <em>null</em> | PLAN_ROW | False | 1 > 16 | 4 | |--Table Scan(OBJECT:([fiddle_7ce3ca94f6e64aaf88f62c57ccca5fdf].[dbo].[docs] AS [d1])) | 1 | 5 | 3 | Table Scan | Table Scan | OBJECT:([fiddle_7ce3ca94f6e64aaf88f62c57ccca5fdf].[dbo].[docs] AS [d1]) | <em>null</em> | 4 | 0.0032035 | 8.29E-05 | 9 | 0.0035351 | <em>null</em> | <em>null</em> | PLAN_ROW | False | 4 > </pre> <!-- --> > -------------------------------------------------------------------------------- > -- Or use XML to see the visual representation, thanks to Justin Pealing and > -- his library: https://github.com/JustinPealing/html-query-plan > -------------------------------------------------------------------------------- > set statistics xml on; > select max('Do this to get execution plans and stats') "Execution Plans" > from docs d1 cross join docs d2; > set statistics xml off; > GO > > <pre> > | Execution Plans | > | :--------------------------------------- | > | Do this to get execution plans and stats | > > | Microsoft SQL Server 2005 XML Showplan | > | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | > | &lt;ShowPlanXML xmlns=&quot;http://schemas.microsoft.com/sqlserver/2004/07/showplan&quot; Version=&quot;1.481&quot; Build=&quot;14.0.3030.27&quot;&gt;&lt;BatchSequence&gt;&lt;Batch&gt;&lt;Statements&gt;&lt;StmtSimple StatementText=&quot;select max(&amp;apos;Do this to get execution plans and stats&amp;apos;) &amp;quot;Execution Plans&amp;quot;&amp;#xa;from docs d1 cross join docs d2&quot; StatementId=&quot;1&quot; StatementCompId=&quot;2&quot; StatementType=&quot;SELECT&quot; RetrievedFromCache=&quot;true&quot; StatementSubTreeCost=&quot;0.00689848&quot; StatementEstRows=&quot;1&quot; SecurityPolicyApplied=&quot;false&quot; StatementOptmLevel=&quot;FULL&quot; QueryHash=&quot;0x9BEA186AE6E95E86&quot; QueryPlanHash=&quot;0xC79ED7BBB7BC4A7F&quot; StatementOptmEarlyAbortReason=&quot;GoodEnoughPlanFound&quot; CardinalityEstimationModelVersion=&quot;140&quot;&gt;&lt;StatementSetOptions QUOTED_IDENTIFIER=&quot;true&quot; ARITHABORT=&quot;true&quot; CONCAT_NULL_YIELDS_NULL=&quot;true&quot; ANSI_NULLS=&quot;true&quot; ANSI_PADDING=&quot;true&quot; ANSI_WARNINGS=&quot;true&quot; NUMERIC_ROUNDABORT=&quot;false&quot;&gt;&lt;/StatementSetOptions&gt;&lt;QueryPlan DegreeOfParallelism=&quot;0&quot; NonParallelPlanReason=&quot;NoParallelPlansInDesktopOrExpressEdition&quot; CachedPlanSize=&quot;16&quot; CompileTime=&quot;0&quot; CompileCPU=&quot;0&quot; CompileMemory=&quot;152&quot;&gt;&lt;MemoryGrantInfo SerialRequiredMemory=&quot;0&quot; SerialDesiredMemory=&quot;0&quot;&gt;&lt;/MemoryGrantInfo&gt;&lt;OptimizerHardwareDependentProperties EstimatedAvailableMemoryGrant=&quot;419378&quot; EstimatedPagesCached=&quot;26211&quot; EstimatedAvailableDegreeOfParallelism=&quot;1&quot; MaxCompileMemory=&quot;2058336&quot;&gt;&lt;/OptimizerHardwareDependentProperties&gt;&lt;TraceFlags IsCompileTime=&quot;1&quot;&gt;&lt;TraceFlag Value=&quot;8017&quot; Scope=&quot;Global&quot;&gt;&lt;/TraceFlag&gt;&lt;/TraceFlags&gt;&lt;TraceFlags IsCompileTime=&quot;0&quot;&gt;&lt;TraceFlag Value=&quot;8017&quot; Scope=&quot;Global&quot;&gt;&lt;/TraceFlag&gt;&lt;/TraceFlags&gt;&lt;QueryTimeStats ElapsedTime=&quot;0&quot; CpuTime=&quot;0&quot;&gt;&lt;/QueryTimeStats&gt;&lt;RelOp NodeId=&quot;0&quot; PhysicalOp=&quot;Stream Aggregate&quot; LogicalOp=&quot;Aggregate&quot; EstimateRows=&quot;1&quot; EstimateIO=&quot;0&quot; EstimateCPU=&quot;1.01e-005&quot; AvgRowSize=&quot;31&quot; EstimatedTotalSubtreeCost=&quot;0.00689848&quot; Parallel=&quot;0&quot; EstimateRebinds=&quot;0&quot; EstimateRewinds=&quot;0&quot; EstimatedExecutionMode=&quot;Row&quot;&gt;&lt;OutputList&gt;&lt;ColumnReference Column=&quot;Expr1004&quot;&gt;&lt;/ColumnReference&gt;&lt;/OutputList&gt;&lt;RunTimeInformation&gt;&lt;RunTimeCountersPerThread Thread=&quot;0&quot; ActualRows=&quot;1&quot; Batches=&quot;0&quot; ActualExecutionMode=&quot;Row&quot; ActualElapsedms=&quot;0&quot; ActualCPUms=&quot;0&quot; ActualEndOfScans=&quot;1&quot; ActualExecutions=&quot;1&quot;&gt;&lt;/RunTimeCountersPerThread&gt;&lt;/RunTimeInformation&gt;&lt;StreamAggregate&gt;&lt;DefinedValues&gt;&lt;DefinedValue&gt;&lt;ColumnReference Column=&quot;Expr1004&quot;&gt;&lt;/ColumnReference&gt;&lt;ScalarOperator ScalarString=&quot;MAX(&amp;apos;Do this to get execution plans and stats&amp;apos;)&quot;&gt;&lt;Aggregate Distinct=&quot;0&quot; AggType=&quot;MAX&quot;&gt;&lt;ScalarOperator&gt;&lt;Const ConstValue=&quot;&amp;apos;Do this to get execution plans and stats&amp;apos;&quot;&gt;&lt;/Const&gt;&lt;/ScalarOperator&gt;&lt;/Aggregate&gt;&lt;/ScalarOperator&gt;&lt;/DefinedValue&gt;&lt;/DefinedValues&gt;&lt;RelOp NodeId=&quot;1&quot; PhysicalOp=&quot;Nested Loops&quot; LogicalOp=&quot;Inner Join&quot; EstimateRows=&quot;16&quot; EstimateIO=&quot;0&quot; EstimateCPU=&quot;6.688e-005&quot; AvgRowSize=&quot;9&quot; EstimatedTotalSubtreeCost=&quot;0.00688838&quot; Parallel=&quot;0&quot; EstimateRebinds=&quot;0&quot; EstimateRewinds=&quot;0&quot; EstimatedExecutionMode=&quot;Row&quot;&gt;&lt;OutputList&gt;&lt;/OutputList&gt;&lt;Warnings NoJoinPredicate=&quot;1&quot;&gt;&lt;/Warnings&gt;&lt;RunTimeInformation&gt;&lt;RunTimeCountersPerThread Thread=&quot;0&quot; ActualRows=&quot;16&quot; Batches=&quot;0&quot; ActualExecutionMode=&quot;Row&quot; ActualElapsedms=&quot;0&quot; ActualCPUms=&quot;0&quot; ActualEndOfScans=&quot;1&quot; ActualExecutions=&quot;1&quot;&gt;&lt;/RunTimeCountersPerThread&gt;&lt;/RunTimeInformation&gt;&lt;NestedLoops Optimized=&quot;0&quot;&gt;&lt;RelOp NodeId=&quot;2&quot; PhysicalOp=&quot;Table Scan&quot; LogicalOp=&quot;Table Scan&quot; EstimateRows=&quot;4&quot; EstimatedRowsRead=&quot;4&quot; EstimateIO=&quot;0.003125&quot; EstimateCPU=&quot;0.0001614&quot; AvgRowSize=&quot;9&quot; EstimatedTotalSubtreeCost=&quot;0.0032864&quot; TableCardinality=&quot;4&quot; Parallel=&quot;0&quot; EstimateRebinds=&quot;0&quot; EstimateRewinds=&quot;0&quot; EstimatedExecutionMode=&quot;Row&quot;&gt;&lt;OutputList&gt;&lt;/OutputList&gt;&lt;RunTimeInformation&gt;&lt;RunTimeCountersPerThread Thread=&quot;0&quot; ActualRows=&quot;4&quot; Batches=&quot;0&quot; ActualExecutionMode=&quot;Row&quot; ActualElapsedms=&quot;0&quot; ActualCPUms=&quot;0&quot; ActualScans=&quot;1&quot; ActualLogicalReads=&quot;1&quot; ActualPhysicalReads=&quot;0&quot; ActualReadAheads=&quot;0&quot; ActualLobLogicalReads=&quot;0&quot; ActualLobPhysicalReads=&quot;0&quot; ActualLobReadAheads=&quot;0&quot; ActualRowsRead=&quot;4&quot; ActualEndOfScans=&quot;1&quot; ActualExecutions=&quot;1&quot;&gt;&lt;/RunTimeCountersPerThread&gt;&lt;/RunTimeInformation&gt;&lt;TableScan Ordered=&quot;0&quot; ForcedIndex=&quot;0&quot; ForceScan=&quot;0&quot; NoExpandHint=&quot;0&quot; Storage=&quot;RowStore&quot;&gt;&lt;DefinedValues&gt;&lt;/DefinedValues&gt;&lt;Object Database=&quot;[fiddle_7ce3ca94f6e64aaf88f62c57ccca5fdf]&quot; Schema=&quot;[dbo]&quot; Table=&quot;[docs]&quot; Alias=&quot;[d2]&quot; IndexKind=&quot;Heap&quot; Storage=&quot;RowStore&quot;&gt;&lt;/Object&gt;&lt;/TableScan&gt;&lt;/RelOp&gt;&lt;RelOp NodeId=&quot;3&quot; PhysicalOp=&quot;Table Scan&quot; LogicalOp=&quot;Table Scan&quot; EstimateRows=&quot;4&quot; EstimatedRowsRead=&quot;4&quot; EstimateIO=&quot;0.0032035&quot; EstimateCPU=&quot;8.29e-005&quot; AvgRowSize=&quot;9&quot; EstimatedTotalSubtreeCost=&quot;0.0035351&quot; TableCardinality=&quot;4&quot; Parallel=&quot;0&quot; EstimateRebinds=&quot;0&quot; EstimateRewinds=&quot;3&quot; EstimatedExecutionMode=&quot;Row&quot;&gt;&lt;OutputList&gt;&lt;/OutputList&gt;&lt;RunTimeInformation&gt;&lt;RunTimeCountersPerThread Thread=&quot;0&quot; ActualRows=&quot;16&quot; Batches=&quot;0&quot; ActualExecutionMode=&quot;Row&quot; ActualElapsedms=&quot;0&quot; ActualCPUms=&quot;0&quot; ActualScans=&quot;1&quot; ActualLogicalReads=&quot;4&quot; ActualPhysicalReads=&quot;0&quot; ActualReadAheads=&quot;0&quot; ActualLobLogicalReads=&quot;0&quot; ActualLobPhysicalReads=&quot;0&quot; ActualLobReadAheads=&quot;0&quot; ActualRowsRead=&quot;16&quot; ActualEndOfScans=&quot;4&quot; ActualExecutions=&quot;4&quot;&gt;&lt;/RunTimeCountersPerThread&gt;&lt;/RunTimeInformation&gt;&lt;TableScan Ordered=&quot;0&quot; ForcedIndex=&quot;0&quot; ForceScan=&quot;0&quot; NoExpandHint=&quot;0&quot; Storage=&quot;RowStore&quot;&gt;&lt;DefinedValues&gt;&lt;/DefinedValues&gt;&lt;Object Database=&quot;[fiddle_7ce3ca94f6e64aaf88f62c57ccca5fdf]&quot; Schema=&quot;[dbo]&quot; Table=&quot;[docs]&quot; Alias=&quot;[d1]&quot; IndexKind=&quot;Heap&quot; Storage=&quot;RowStore&quot;&gt;&lt;/Object&gt;&lt;/TableScan&gt;&lt;/RelOp&gt;&lt;/NestedLoops&gt;&lt;/RelOp&gt;&lt;/StreamAggregate&gt;&lt;/RelOp&gt;&lt;/QueryPlan&gt;&lt;/StmtSimple&gt;&lt;/Statements&gt;&lt;/Batch&gt;&lt;/BatchSequence&gt;&lt;/ShowPlanXML&gt; | > </pre> <!-- --> > -------------------------------------------------------------------------------- > -- ② Integers table > -------------------------------------------------------------------------------- > with > p0(i) as (select 1 union all select 1 union all select 1 union all select 1) > , p1(i) as (select 1 from p0 as a, p0 as b, p0 as c, p0 as d, p0 as e)--1K rows > , p2(i) as (select 1 from p1 as a, p1 as b)--1M rows > select row_number() over(order by i) as val > into integers > from p2 > GO > > <pre> 1048576 rows affected > </pre> *db<>fiddle [here](https://dbfiddle.uk/?rdbms=sqlserver_2017&fiddle=9bcd60e2bcd7966fc3be475addab8eb2)*