4

To serve as RM (resource manager) in distributed transaction, DBMS must implement 2-phase commit. Like in PostgreSQL, when you first "pre-commit" local transaction:

PREPARE TRANSACTION 'foo'

then commit it:

COMMIT PREPARED 'foo'

My question is: does MS SQLServer supports such functionality?

Alex Salauyou
  • 14,185
  • 5
  • 45
  • 67
  • 1
    Yes - Sql Server can enlist in [DTC / XA transactions](https://msdn.microsoft.com/en-us/library/aa342335(v=sql.110).aspx) – StuartLC Feb 26 '15 at 10:30
  • @StuartLC Didn't try yet but it seems to be exactly what I need. Thanx! – Alex Salauyou Feb 26 '15 at 10:45
  • Distributed transaction syntax for Sql Server is `BEGIN DISTRIBUTED TRANSACTION`. Also, FWIW if you have a .Net App, you should look into `System.Transactions.TransactionScope`, which will automatically manage transactions, escalating to distributed only if needed - this is a good thing, as distributed transactions can be lock-heavy. – StuartLC Feb 26 '15 at 10:55
  • @StuartLC no, I have a Java application and looking for SQL Server implementation as resource manager, not transaction manager. Though, link above is very helpful. – Alex Salauyou Feb 27 '15 at 09:31

0 Answers0