Skip to content

Commit affb820

Browse files
Merge pull request #34561 from rwestMSFT/rw-0627-cte
Rework placement of CTE guidelines
2 parents 654f03b + a580952 commit affb820

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

docs/t-sql/queries/with-common-table-expression-transact-sql.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,17 @@ If more than one *CTE_query_definition* is defined, the query definitions must b
6565

6666
## Usage guidelines
6767

68-
- [Guidelines for common table expressions](#guidelines-for-nonrecursive-common-table-expressions)
68+
Query results from common table expressions aren't materialized. Each outer reference to the named result set requires the defined query to be re-executed. For queries that require multiple references to the named result set, consider using a [temporary object](../statements/create-table-transact-sql.md#temporary-tables) instead.
69+
70+
You can't execute a stored procedure in a common table expression.
71+
72+
For usage guidelines about recursive and nonrecursive CTEs, see the following sections.
73+
74+
- [Guidelines for nonrecursive common table expressions](#guidelines-for-nonrecursive-common-table-expressions)
6975
- [Guidelines for recursive common table expressions](#guidelines-for-recursive-common-table-expressions)
7076

77+
<a id="guidelines-for-creating-and-using-common-table-expressions"></a>
78+
7179
### Guidelines for nonrecursive common table expressions
7280

7381
> [!NOTE]
@@ -83,10 +91,6 @@ Specifying more than one `WITH` clause in a CTE isn't allowed. For example, if a
8391

8492
For more information on nested CTEs in Microsoft Fabric, see [Nested Common Table Expression (CTE) in Fabric data warehousing (Transact-SQL)](nested-common-table-expression.md?view=fabric&preserve-view=true).
8593

86-
Query results from common table expressions aren't materialized. Each outer reference to the named result set requires the defined query to be re-executed. For queries that require multiple references to the named result set, consider using a [temporary object](../statements/create-table-transact-sql.md#temporary-tables) instead.
87-
88-
You can't execute a stored procedure in a common table expression.
89-
9094
The following clauses can't be used in the *CTE_query_definition*:
9195

9296
- `ORDER BY` (except when a `TOP` or `OFFSET/FETCH` clause is specified)

0 commit comments

Comments
 (0)