Skip to content

Commit 8ab6bbf

Browse files
authored
Merge pull request #110024 from Kat-Campise/rebrand_sqldw_v4
rebrand sqldw third 6
2 parents 899aa77 + e72f6d8 commit 8ab6bbf

6 files changed

+129
-92
lines changed

articles/synapse-analytics/sql-data-warehouse/sql-data-warehouse-develop-transactions.md

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: Using transactions
3-
description: Tips for implementing transactions in Azure SQL Data Warehouse for developing solutions.
2+
title: Use transactions in Synapse SQL pool
3+
description: This article includes tips for implementing transactions and developing solutions in Synapse SQL pool.
44
services: synapse-analytics
55
author: XiaoyuMSFT
66
manager: craigg
@@ -13,19 +13,23 @@ ms.reviewer: igorstan
1313
ms.custom: seo-lt-2019
1414
---
1515

16-
# Using transactions in SQL Data Warehouse
17-
Tips for implementing transactions in Azure SQL Data Warehouse for developing solutions.
16+
# Use transactions in Synapse SQL pool
17+
This article includes tips for implementing transactions and developing solutions in SQL pool.
1818

1919
## What to expect
20-
As you would expect, SQL Data Warehouse supports transactions as part of the data warehouse workload. However, to ensure the performance of SQL Data Warehouse is maintained at scale some features are limited when compared to SQL Server. This article highlights the differences and lists the others.
20+
As you would expect, SQL pool supports transactions as part of the data warehouse workload. However, to ensure SQL pool is maintained at scale, some features are limited when compared to SQL Server. This article highlights the differences.
2121

2222
## Transaction isolation levels
23-
SQL Data Warehouse implements ACID transactions. The isolation level of the transactional support is default to READ UNCOMMITTED. You can change it to READ COMMITTED SNAPSHOT ISOLATION by turning ON the READ_COMMITTED_SNAPSHOT database option for a user database when connected to the master database. Once enabled, all transactions in this database are executed under READ COMMITTED SNAPSHOT ISOLATION and setting READ UNCOMMITTED on session level will not be honored. Check [ALTER DATABASE SET options (Transact-SQL)](https://docs.microsoft.com/sql/t-sql/statements/alter-database-transact-sql-set-options?view=azure-sqldw-latest) for details.
23+
SQL pool implements ACID transactions. The isolation level of the transactional support is default to READ UNCOMMITTED. You can change it to READ COMMITTED SNAPSHOT ISOLATION by turning ON the READ_COMMITTED_SNAPSHOT database option for a user database when connected to the master database.
24+
25+
Once enabled, all transactions in this database are executed under READ COMMITTED SNAPSHOT ISOLATION and setting READ UNCOMMITTED on session level will not be honored. Check [ALTER DATABASE SET options (Transact-SQL)](https://docs.microsoft.com/sql/t-sql/statements/alter-database-transact-sql-set-options?view=azure-sqldw-latest) for details.
2426

2527
## Transaction size
26-
A single data modification transaction is limited in size. The limit is applied per distribution. Therefore, the total allocation can be calculated by multiplying the limit by the distribution count. To approximate the maximum number of rows in the transaction divide the distribution cap by the total size of each row. For variable length columns, consider taking an average column length rather than using the maximum size.
28+
A single data modification transaction is limited in size. The limit is applied per distribution. Therefore, the total allocation can be calculated by multiplying the limit by the distribution count.
29+
30+
To approximate the maximum number of rows in the transaction divide the distribution cap by the total size of each row. For variable length columns, consider taking an average column length rather than using the maximum size.
2731

28-
In the table below the following assumptions have been made:
32+
In the following table, two assumptions have been made:
2933

3034
* An even distribution of data has occurred
3135
* The average row length is 250 bytes
@@ -79,14 +83,17 @@ To optimize and minimize the amount of data written to the log, please refer to
7983
>
8084
8185
## Transaction state
82-
SQL Data Warehouse uses the XACT_STATE() function to report a failed transaction using the value -2. This value means the transaction has failed and is marked for rollback only.
86+
SQL pool uses the XACT_STATE() function to report a failed transaction using the value -2. This value means the transaction has failed and is marked for rollback only.
8387

8488
> [!NOTE]
85-
> The use of -2 by the XACT_STATE function to denote a failed transaction represents different behavior to SQL Server. SQL Server uses the value -1 to represent an uncommittable transaction. SQL Server can tolerate some errors inside a transaction without it having to be marked as uncommittable. For example `SELECT 1/0` would cause an error but not force a transaction into an uncommittable state. SQL Server also permits reads in the uncommittable transaction. However, SQL Data Warehouse does not let you do this. If an error occurs inside a SQL Data Warehouse transaction it will automatically enter the -2 state and you will not be able to make any further select statements until the statement has been rolled back. It is therefore important to check that your application code to see if it uses XACT_STATE() as you may need to make code modifications.
86-
>
87-
>
89+
> The use of -2 by the XACT_STATE function to denote a failed transaction represents different behavior to SQL Server. SQL Server uses the value -1 to represent an uncommittable transaction. SQL Server can tolerate some errors inside a transaction without it having to be marked as uncommittable. For example, `SELECT 1/0` would cause an error but not force a transaction into an uncommittable state.
8890
89-
For example, in SQL Server you might see a transaction that looks like the following:
91+
SQL Server also permits reads in the uncommittable transaction. However, SQL pool does not let you do this. If an error occurs inside a SQL pool transaction, it will automatically enter the -2 state and you will not be able to make any further select statements until the statement has been rolled back.
92+
93+
As such, it's important to check that your application code to see if it uses XACT_STATE() as you may need to make code modifications.
94+
95+
96+
For example, in SQL Server, you might see a transaction that looks like the following:
9097

9198
```sql
9299
SET NOCOUNT ON;
@@ -127,11 +134,11 @@ SELECT @xact_state AS TransactionState;
127134
The preceding code gives the following error message:
128135

129136
Msg 111233, Level 16, State 1, Line 1
130-
111233; The current transaction has aborted, and any pending changes have been rolled back. Cause: A transaction in a rollback-only state was not explicitly rolled back before a DDL, DML, or SELECT statement.
137+
111233; The current transaction has aborted, and any pending changes have been rolled back. The cause of this issue is that a transaction in a rollback-only state not being explicitly rolled back before a DDL, DML, or SELECT statement.
131138

132139
You won't get the output of the ERROR_* functions.
133140

134-
In SQL Data Warehouse the code needs to be slightly altered:
141+
In SQL pool the code needs to be slightly altered:
135142

136143
```sql
137144
SET NOCOUNT ON;
@@ -173,17 +180,19 @@ The expected behavior is now observed. The error in the transaction is managed a
173180
All that has changed is that the ROLLBACK of the transaction had to happen before the read of the error information in the CATCH block.
174181

175182
## Error_Line() function
176-
It is also worth noting that SQL Data Warehouse does not implement or support the ERROR_LINE() function. If you have this in your code, you need to remove it to be compliant with SQL Data Warehouse. Use query labels in your code instead to implement equivalent functionality. For more details, see the [LABEL](sql-data-warehouse-develop-label.md) article.
183+
It is also worth noting that SQL pool does not implement or support the ERROR_LINE() function. If you have this in your code, you need to remove it to be compliant with SQL pool.
184+
185+
Use query labels in your code instead to implement equivalent functionality. For more details, see the [LABEL](sql-data-warehouse-develop-label.md) article.
177186

178187
## Using THROW and RAISERROR
179-
THROW is the more modern implementation for raising exceptions in SQL Data Warehouse but RAISERROR is also supported. There are a few differences that are worth paying attention to however.
188+
THROW is the more modern implementation for raising exceptions in SQL pool but RAISERROR is also supported. There are a few differences that are worth paying attention to however.
180189

181190
* User-defined error messages numbers cannot be in the 100,000 - 150,000 range for THROW
182191
* RAISERROR error messages are fixed at 50,000
183192
* Use of sys.messages is not supported
184193

185194
## Limitations
186-
SQL Data Warehouse does have a few other restrictions that relate to transactions.
195+
SQL pool does have a few other restrictions that relate to transactions.
187196

188197
They are as follows:
189198

@@ -195,5 +204,5 @@ They are as follows:
195204
* No support for DDL such as CREATE TABLE inside a user-defined transaction
196205

197206
## Next steps
198-
To learn more about optimizing transactions, see [Transactions best practices](sql-data-warehouse-develop-best-practices-transactions.md). To learn about other SQL Data Warehouse best practices, see [SQL Data Warehouse best practices](sql-data-warehouse-best-practices.md).
207+
To learn more about optimizing transactions, see [Transactions best practices](sql-data-warehouse-develop-best-practices-transactions.md). To learn about other SQL pool best practices, see [SQL pool best practices](sql-data-warehouse-best-practices.md).
199208

articles/synapse-analytics/sql-data-warehouse/sql-data-warehouse-develop-user-defined-schemas.md

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Using user-defined schemas
3-
description: Tips for using T-SQL user-defined schemas in Azure SQL Data Warehouse for developing solutions.
3+
description: Tips for using T-SQL user-defined schemas to develop solutions in Synapse SQL pool.
44
services: synapse-analytics
55
author: XiaoyuMSFT
66
manager: craigg
@@ -13,42 +13,44 @@ ms.reviewer: igorstan
1313
ms.custom: seo-lt-2019
1414
---
1515

16-
# Using user-defined schemas in SQL Data Warehouse
17-
Tips for using T-SQL user-defined schemas in Azure SQL Data Warehouse for developing solutions.
16+
# User-defined schemas in Synapse SQL pool
17+
This article focuses on providing several tips for using T-SQL user-defined schemas to develop solutions in Synapse SQL pool.
1818

1919
## Schemas for application boundaries
2020

21-
Traditional data warehouses often use separate databases to create application boundaries based on either workload, domain or security. For example, a traditional SQL Server data warehouse might include a staging database, a data warehouse database, and some data mart databases. In this topology each database operates as a workload and security boundary in the architecture.
21+
Traditional data warehouses often use separate databases to create application boundaries based on either workload, domain or security.
2222

23-
By contrast, SQL Data Warehouse runs the entire data warehouse workload within one database. Cross database joins are not permitted. Therefore SQL Data Warehouse expects all tables used by the warehouse to be stored within the one database.
23+
As an example, a traditional SQL Server data warehouse might include a staging database, a data warehouse database, and some data mart databases. In this topology, each database operates as a workload and security boundary in the architecture.
24+
25+
By contrast, SQL pool runs the entire data warehouse workload within one database. Cross database joins aren't permitted. SQL pool expects all tables used by the warehouse to be stored within the one database.
2426

2527
> [!NOTE]
26-
> SQL Data Warehouse does not support cross database queries of any kind. Consequently, data warehouse implementations that leverage this pattern will need to be revised.
28+
> SQL pool does not support cross database queries of any kind. Consequently, data warehouse implementations that leverage this pattern will need to be revised.
2729
>
2830
>
2931
3032
## Recommendations
31-
These are recommendations for consolidating workloads, security, domain and functional boundaries by using user defined schemas
33+
What follows are recommendations for consolidating workloads, security, domain, and functional boundaries by using user-defined schemas:
3234

33-
1. Use one SQL Data Warehouse database to run your entire data warehouse workload
34-
2. Consolidate your existing data warehouse environment to use one SQL Data Warehouse database
35-
3. Leverage **user-defined schemas** to provide the boundary previously implemented using databases.
35+
- Use one SQL pool database to run your entire data warehouse workload.
36+
- Consolidate your existing data warehouse environment to use one SQL pool database.
37+
- Leverage **user-defined schemas** to provide the boundary previously implemented using databases.
3638

37-
If user-defined schemas have not been used previously then you have a clean slate. Simply use the old database name as the basis for your user-defined schemas in the SQL Data Warehouse database.
39+
If user-defined schemas have not been used previously, then you have a clean slate. Use the old database name as the basis for your user-defined schemas in the SQL pool database.
3840

39-
If schemas have already been used then you have a few options:
41+
If schemas have already been used, then you have a few options:
4042

41-
1. Remove the legacy schema names and start fresh
42-
2. Retain the legacy schema names by pre-pending the legacy schema name to the table name
43-
3. Retain the legacy schema names by implementing views over the table in an extra schema to re-create the old schema structure.
43+
- Remove the legacy schema names and start fresh.
44+
- Retain the legacy schema names by pre-pending the legacy schema name to the table name.
45+
- Retain the legacy schema names by implementing views over the table in an extra schema to re-create the old schema structure.
4446

4547
> [!NOTE]
46-
> On first inspection option 3 may seem like the most appealing option. However, the devil is in the detail. Views are read only in SQL Data Warehouse. Any data or table modification would need to be performed against the base table. Option 3 also introduces a layer of views into your system. You might want to give this some additional thought if you are using views in your architecture already.
48+
> On first inspection option 3 may seem like the most appealing option. However, the devil is in the detail. Views are read only in SQL pool. Any data or table modification would need to be performed against the base table. Option 3 also introduces a layer of views into your system. You might want to give this some additional thought if you are using views in your architecture already.
4749
>
4850
>
4951
5052
### Examples:
51-
Implement user-defined schemas based on database names
53+
Implement user-defined schemas based on database names:
5254

5355
```sql
5456
CREATE SCHEMA [stg]; -- stg previously database name for staging database
@@ -66,7 +68,7 @@ CREATE TABLE [edw].[customer] -- create data warehouse tables in the edw schema
6668
);
6769
```
6870

69-
Retain legacy schema names by pre-pending them to the table name. Use schemas for the workload boundary.
71+
Keep legacy schema names by pre-pending them to the table name. Use schemas for the workload boundary:
7072

7173
```sql
7274
CREATE SCHEMA [stg]; -- stg defines the staging boundary
@@ -84,7 +86,7 @@ CREATE TABLE [edw].[dim_customer] --pre-pend the old schema name to the table an
8486
);
8587
```
8688

87-
Retain legacy schema names using views
89+
Keep legacy schema names using views:
8890

8991
```sql
9092
CREATE SCHEMA [stg]; -- stg defines the staging boundary
@@ -112,7 +114,7 @@ FROM [edw].customer
112114
```
113115

114116
> [!NOTE]
115-
> Any change in schema strategy needs a review of the security model for the database. In many cases you might be able to simplify the security model by assigning permissions at the schema level. If more granular permissions are required then you can use database roles.
117+
> Any change in schema strategy needs a review of the security model for the database. In many cases, you might be able to simplify the security model by assigning permissions at the schema level. If more granular permissions are required, then you can use database roles.
116118
>
117119
>
118120

articles/synapse-analytics/sql-data-warehouse/sql-data-warehouse-develop-variable-assignment.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Assign variables
3-
description: Tips for assigning T-SQL variables in Azure SQL Data Warehouse for developing solutions.
3+
description: In this article, you'll find essential tips for assigning T-SQL variables in SQL pool.
44
services: synapse-analytics
55
author: XiaoyuMSFT
66
manager: craigg
@@ -13,36 +13,36 @@ ms.reviewer: igorstan
1313
ms.custom: seo-lt-2019
1414
---
1515

16-
# Assigning variables in Azure SQL Data Warehouse
16+
# Assign variables in Synapse SQL pool
1717

18-
Tips for assigning T-SQL variables in Azure SQL Data Warehouse for developing solutions.
18+
In this article, you'll find essential tips for assigning T-SQL variables in SQL pool.
1919

20-
## Setting variables with DECLARE
20+
## Set variables with DECLARE
2121

22-
Variables in SQL Data Warehouse are set using the `DECLARE` statement or the `SET` statement. Initializing variables with DECLARE is one of the most flexible ways to set a variable value in SQL Data Warehouse.
22+
Variables in SQL pool are set using the `DECLARE` statement or the `SET` statement. Initializing variables with DECLARE is one of the most flexible ways to set a variable value in SQL pool.
2323

2424
```sql
2525
DECLARE @v int = 0
2626
;
2727
```
2828

29-
You can also use DECLARE to set more than one variable at a time. You cannot use SELECT or UPDATE to do the following:
29+
You can also use DECLARE to set more than one variable at a time. You can't use SELECT or UPDATE to do the following:
3030

3131
```sql
3232
DECLARE @v INT = (SELECT TOP 1 c_customer_sk FROM Customer where c_last_name = 'Smith')
3333
, @v1 INT = (SELECT TOP 1 c_customer_sk FROM Customer where c_last_name = 'Jones')
3434
;
3535
```
3636

37-
You cannot initialize and use a variable in the same DECLARE statement. To illustrate the point, the following example is **not** allowed since @p1 is both initialized and used in the same DECLARE statement. The following example gives an error.
37+
You can't initialize and use a variable in the same DECLARE statement. To illustrate the point, the following example is **not** allowed since @p1 is both initialized and used in the same DECLARE statement. As such, the following example gives an error:
3838

3939
```sql
4040
DECLARE @p1 int = 0
4141
, @p2 int = (SELECT COUNT (*) FROM sys.types where is_user_defined = @p1 )
4242
;
4343
```
4444

45-
## Setting values with SET
45+
## Set values with SET
4646

4747
SET is a common method for setting a single variable.
4848

@@ -59,7 +59,7 @@ You can only set one variable at a time with SET. However, compound operators ar
5959

6060
## Limitations
6161

62-
You cannot use UPDATE for variable assignment.
62+
You can't use UPDATE for variable assignment.
6363

6464
## Next steps
6565

0 commit comments

Comments
 (0)