2 phase commit by example

Posted on 2001-06-14
Last Modified: 2008-02-01
Can anyone explain me 2phase commit by small example?
I've two database server base1 and base2.How can i implement 2 phase commit?Pls expalin me with a small live example used in industry..I'm using sql 2000.
Question by:vivekkj

Expert Comment

ID: 6194057
What you want to do?

To phase commit is implemented in MS DTC (Distributed Transaction Coordinator). As a programmer and administrator, you do not have to do it yourself. If you use middle tier transaction logic, the only thing you have to do is to implement transaction in your component.



Expert Comment

ID: 6195487
Just do
Begin distributed Tran
<Sql Statements>

Commit tran

Expert Comment

ID: 6195489
Just do
Begin distributed Tran
<Sql Statements>

Commit tran
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

LVL 18

Expert Comment

ID: 6195858
Why do you want a two phase commit?

Basically this is only used where the transaction controller doesn't have close control over all entities involved in the transaction.

The basic idea is that the first phase is 'are we all ready to commit?', second phase 'go ahead and commit?'
Before responding to the first phase the entity is expected to prepare the system so that nothing will hold up the commit.

Accepted Solution

sefa earned 100 total points
ID: 6199744
suppose you have two SQL Servers server_A and server_B
suppose you have two databases server_A.db_1 and server_B.db_2
suppose you have two table server_A.db_1..table_1 and server_B.db_2..table_2

if you want to insert a row into server_A.db_1..table_1 and update a row from server_B.db_2..table_2
in the same transaction you must use distrubted transaction. to do so,
you should place your insert and update sql statements into

insert into server_A.db_1..table_1 values('hello')
update server_B.db_2..table_2 set my_col='hello'
-- or if any error occured then

In this example both insert and update are succesful or not.

to support this feature MS DTC service must be running.

Expert Comment

ID: 6900192
ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101 or Netminder will return to finalize these if still open in seven days.  Please post closing recommendations before that time.

Question(s) below appears to have been abandoned. Your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response.  This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database.  If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
   --> Post comments for expert of your intention to delete and why
   --> You cannot delete a question with comments, special handling by a Moderator is required.

For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
Please click the Help Desk link on the left for Member Guidelines, Member Agreement and the Question/Answer process for further information, if needed.

Click you Member Profile to view your question history and keep them all current with updates as the collaboration effort continues, to track all your open and locked questions at this site.  If you are an EE Pro user, use the Power Search option to find them.  Anytime you have questions which are LOCKED with a Proposed Answer but does not serve your needs, please reject it and add comments as to why.  In addition, when you do grade the question, if the grade is less than an A, please add a comment as to why.  This helps all involved, as well as future persons who may access this item in the future to seek help.

To view your open questions, please click the following link(s) and keep them all current with updates.

To view your locked questions, please click the following link(s) and evaluate the proposed answer.

------------>  EXPERTS:  Please leave any comments regarding your closing recommendations if this item remains inactive another seven (7) days.  Also, if you are interested in the cleanup effort, please click this link

Moderators will finalize this question if still open in 7 days, by either moving this to the PAQ (Previously Asked Questions) at zero points, deleting it or awarding expert(s) when recommendations are made, or an independent determination can be made.  Expert input is always appreciated to determine the fair outcome.
Thank you everyone.
Moderator @ Experts Exchange

P.S.  For any year 2000 questions, special attention is needed to ensure the first correct response is awarded, since they are not in the comment date order, but rather in Member ID order.

Expert Comment

ID: 6992946
Force-accepted by
CS Moderator

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
export sql results to csv 6 36
T-SQL: New to using transactions 9 31
Merge two rows in SQL 4 13
Proper Case SQL Command 2 10
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question