Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Commit 46477af

Browse files
authored
Merge pull request #10195 from MightyPen/reuse200
Fixes Issue 2107, clarifies MSDTC for Azure SQL DB. Article rewritten.
2 parents ac1af7e + b13ba46 commit 46477af

1 file changed

Lines changed: 54 additions & 15 deletions

File tree

Lines changed: 54 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
title: "Performing Distributed Transactions | Microsoft Docs"
2+
title: "Create a distributed transactions | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "03/14/2017"
4+
ms.date: "05/13/2019"
55
ms.prod: sql
66
ms.prod_service: "database-engine, sql-database, sql-data-warehouse, pdw"
77
ms.reviewer: ""
@@ -19,19 +19,58 @@ ms.author: genemi
1919
manager: craigg
2020
monikerRange: ">=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||=sqlallproducts-allversions||>=sql-server-linux-2017||=azuresqldb-mi-current"
2121
---
22-
# Performing Transactions - Distributed Transactions
22+
# Create a distributed transaction
23+
2324
[!INCLUDE[appliesto-ss-asdb-asdw-pdw-md](../../../includes/appliesto-ss-asdb-asdw-pdw-md.md)]
25+
26+
<!--
27+
The following includes .md file is Empty, as of long before 2019/May/13.
28+
/includes/snac-deprecated.md
29+
-->
30+
2431
[!INCLUDE[SNAC_Deprecated](../../../includes/snac-deprecated.md)]
2532

26-
The Microsoft Distributed Transaction Coordinator (MS DTC) allows applications to extend transactions across two or more instances of [!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)]. It also allows applications to participate in transactions managed by transaction managers that comply with the Open Group DTP XA standard.
27-
28-
Normally, all transaction management commands are sent through the [!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)] Native Client ODBC driver to the server. The application starts a transaction by calling [SQLSetConnectAttr](../../../relational-databases/native-client-odbc-api/sqlsetconnectattr.md) with the autocommit mode turned off. The application then performs the updates comprising the transaction and calls [SQLEndTran](../../../relational-databases/native-client-odbc-api/sqlendtran.md) with either the SQL_COMMIT or SQL_ROLLBACK option.
29-
30-
When using MS DTC, however, MS DTC becomes the transaction manager and the application no longer uses **SQLEndTran**.
31-
32-
When enlisted in a distributed transaction, and then enlist in a second distributed transaction, the [!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)] Native Client ODBC Driver defects from the original distributed transaction and enlists in the new transaction. For more information, see [DTC Programmer's Reference](https://msdn.microsoft.com/library/ms686108\(VS.85\).aspx).
33-
34-
## See Also
35-
[Performing Transactions &#40;ODBC&#41;](https://msdn.microsoft.com/library/f431191a-5762-4f0b-85bb-ac99aff29724)
36-
37-
33+
A distributed transaction can be created for different Microsoft SQL systems in different ways.
34+
35+
## ODBC driver calls the MSDTC for SQL Server on-premises
36+
37+
The Microsoft Distributed Transaction Coordinator (MSDTC) allows applications to extend or _distribute_ a transaction across two or more instances of [!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)]. The distributed transaction works even when the two instances are hosted on separate computers.
38+
39+
MSDTC is installed for Microsoft SQL Server on-premises, but isn't available for Microsoft's Azure SQL Database cloud service.
40+
41+
MSDTC is called by the SQL Server Native Client driver for Open Database Connectivity (ODBC), when your C++ program manages a distributed transaction. The Native Client ODBC driver has a transaction manager that is compliant with the Open Group Distributed Transaction Processing (DTP) XA standard. This compliance is required by MSDTC. Typically, all transaction management commands are sent through this Native Client ODBC driver. The sequence is as follows:
42+
43+
1. Your C++ Native Client ODBC application starts a transaction by calling [SQLSetConnectAttr](../../../relational-databases/native-client-odbc-api/sqlsetconnectattr.md), with the autocommit mode turned off.
44+
45+
2. The application updates some data on SQL Server X on computer A.
46+
47+
3. The application updates some data on SQL Server Y on computer B.
48+
- If an update on SQL Server Y fails, all the uncommitted updates on both SQL Server instances are rolled back.
49+
50+
4. Finally, the the application ends the transaction by calling [SQLEndTran _(1)_](../../../relational-databases/native-client-odbc-api/sqlendtran.md), with either the SQL_COMMIT or SQL_ROLLBACK option.
51+
52+
_(1)_ MSDTC can be invoked without ODBC. In such a case, MSDTC becomes the transaction manager, and the application no longer uses **SQLEndTran**.
53+
54+
### Only one distributed transaction
55+
56+
Suppose that your C++ Native Client ODBC application is enlisted in a distributed transaction. Next the application enlists in a second distributed transaction. In this case, the [!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)] Native Client ODBC driver leaves the original distributed transaction, and enlists in the new distributed transaction.
57+
58+
For more information, see [DTC Programmer's Reference](https://docs.microsoft.com/previous-versions/windows/desktop/ms686108\(v=vs.85\)).
59+
60+
## C# alternative for SQL Database in the cloud
61+
62+
MSDTC isn't supported for either Azure SQL Database or Azure SQL Data Warehouse.
63+
64+
However, a distributed transaction can be created for SQL Database by having your C# program use the .NET class [System.Transactions.TransactionScope](/dotnet/api/system.transactions.transactionscope).
65+
66+
### Other programming languages
67+
68+
The following other programming languages might not provide any support for distributed transactions with the SQL Database service:
69+
70+
- Native C++ that use ODBC drivers
71+
- Linked server using Transact-SQL
72+
- JDBC drivers
73+
74+
## See also
75+
76+
[Performing Transactions (ODBC)](performing-transactions-in-odbc.md)

0 commit comments

Comments
 (0)