You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/synapse-analytics/sql-data-warehouse/sql-data-warehouse-develop-dynamic-sql.md
+9-5Lines changed: 9 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
title: Using dynamic SQL
3
-
description: Tips for using dynamic SQL in Azure SQL Data Warehouse for developing solutions.
3
+
description: Tips for development solutions using dynamic SQL in Synapse SQL pool.
4
4
services: synapse-analytics
5
5
author: XiaoyuMSFT
6
6
manager: craigg
@@ -13,12 +13,16 @@ ms.reviewer: igorstan
13
13
ms.custom: seo-lt-2019
14
14
---
15
15
16
-
# Dynamic SQL in SQL Data Warehouse
17
-
Tips for using dynamic SQL in Azure SQL Data Warehouse for developing solutions.
16
+
# Dynamic SQL in Synapse SQL pool
17
+
Tips for development solutions using dynamic SQL in SQL pool.
18
18
19
19
## Dynamic SQL Example
20
20
21
-
When developing application code for SQL Data Warehouse, you may need to use dynamic sql to help deliver flexible, generic, and modular solutions. SQL Data Warehouse does not support blob data types at this time. Not supporting blob data types might limit the size of your strings since blob data types include both varchar(max) and nvarchar(max) types. If you have used these types in your application code to build large strings, you need to break the code into chunks and use the EXEC statement instead.
21
+
When developing application code for SQL pool, you may need to use Dynamic SQL to help deliver flexible, generic, and modular solutions. SQL pool doesn't support blob data types at this time.
22
+
23
+
Not supporting blob data types might limit the size of your strings since blob data types include both varchar(max) and nvarchar(max) types.
24
+
25
+
If you've used these types in your application code to build large strings, you need to break the code into chunks and use the EXEC statement instead.
Copy file name to clipboardExpand all lines: articles/synapse-analytics/sql-data-warehouse/sql-data-warehouse-develop-group-by-options.md
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
title: Using group by options
3
-
description: Tips for implementing group by options in Azure SQL Data Warehouse for developing solutions.
3
+
description: Tips for implementing group by options in Synapse SQL pool.
4
4
services: synapse-analytics
5
5
author: XiaoyuMSFT
6
6
manager: craigg
@@ -13,21 +13,21 @@ ms.reviewer: igorstan
13
13
ms.custom: seo-lt-2019
14
14
---
15
15
16
-
# Group by options in SQL Data Warehouse
17
-
Tips for implementing group by options in Azure SQL Data Warehouse for developing solutions.
16
+
# Group by options in Synapse SQL pool
18
17
19
-
## What does GROUP BY do?
18
+
In this article, you'll find tips for implementing group by options in SQL pool.
20
19
21
-
The [GROUP BY](/sql/t-sql/queries/select-group-by-transact-sql) T-SQL clause aggregates data to a summary set of rows. GROUP BY has some options that SQL Data Warehouse does not support. These options have workarounds.
20
+
## What does GROUP BY do?
22
21
23
-
These options are
22
+
The [GROUP BY](/sql/t-sql/queries/select-group-by-transact-sql) T-SQL clause aggregates data to a summary set of rows. GROUP BY has some options that SQL pool doesn't support. These options have workarounds, which are as follows:
24
23
25
24
* GROUP BY with ROLLUP
26
25
* GROUPING SETS
27
26
* GROUP BY with CUBE
28
27
29
28
## Rollup and grouping sets options
30
-
The simplest option here is to use UNION ALL instead to perform the rollup rather than relying on the explicit syntax. The result is exactly the same
29
+
30
+
The simplest option here is to use UNION ALL instead to perform the rollup rather than relying on the explicit syntax. The result is exactly the same.
31
31
32
32
The following example using the GROUP BY statement with the ROLLUP option:
33
33
```sql
@@ -79,11 +79,11 @@ JOIN dbo.DimSalesTerritory t ON s.SalesTerritoryKey = t.SalesTerritor
79
79
To replace GROUPING SETS, the sample principle applies. You only need to create UNION ALL sections for the aggregation levels you want to see.
80
80
81
81
## Cube options
82
-
It is possible to create a GROUP BY WITH CUBE using the UNION ALL approach. The problem is that the code can quickly become cumbersome and unwieldy. To mitigate this, you can use this more advanced approach.
82
+
It is possible to create a GROUP BY WITH CUBE using the UNION ALL approach. The problem is that the code can quickly become cumbersome and unwieldy. To mitigate this issue, you can use this more advanced approach.
83
83
84
-
Let's use the example above.
84
+
Using the previous example, the first step is to define the 'cube' that defines all the levels of aggregation that we want to create.
85
85
86
-
The first step is to define the 'cube' that defines all the levels of aggregation that we want to create. It is important to take note of the CROSS JOIN of the two derived tables. This generates all the levels for us. The rest of the code is really there for formatting.
86
+
It is important to take note of the CROSS JOIN of the two derived tables. This generates all the levels for us. The rest of the code is there for formatting:
87
87
88
88
```sql
89
89
CREATE TABLE #Cube
@@ -114,7 +114,7 @@ SELECT Cols
114
114
FROM GrpCube;
115
115
```
116
116
117
-
The following shows the results of the CTAS:
117
+
The following image shows the results of the CTAS:
118
118
119
119

120
120
@@ -141,7 +141,7 @@ WITH
141
141
;
142
142
```
143
143
144
-
The third step is to loop over our cube of columns performing the aggregation. The query will run once for every row in the #Cube temporary table and store the results in the #Results temp table
144
+
The third step is to loop over our cube of columns performing the aggregation. The query will run once for every row in the #Cube temporary table and store the results in the #Results temp table:
145
145
146
146
```sql
147
147
SET @nbr =(SELECTMAX(Seq) FROM#Cube);
@@ -165,7 +165,7 @@ BEGIN
165
165
END
166
166
```
167
167
168
-
Lastly, you can return the results by simply reading from the #Results temporary table
168
+
Lastly, you can return the results by reading from the #Results temporary table:
169
169
170
170
```sql
171
171
SELECT*
@@ -174,7 +174,7 @@ ORDER BY 1,2,3
174
174
;
175
175
```
176
176
177
-
By breaking the code up into sections and generating a looping construct, the code becomes more manageable and maintainable.
177
+
By breaking up the code into sections and generating a looping construct, the code becomes more manageable and maintainable.
178
178
179
179
## Next steps
180
180
For more development tips, see [development overview](sql-data-warehouse-overview-develop.md).
0 commit comments