Transactions in SQL

  • I have some doubts related to transactions in SQL.

    Connection 1 open for DB1 database

    Begin transaction for Connection 1

    Run the commands on Connection 1

    Connection 2 open for DB2 database

    Begin transaction for Connection 2

    Run the commands on Connection 2

    Commit transaction for Connection 2

    Commit transaction for Connection 1

    If commit transaction on Connection 1 fails(rollback) then transaction on connection 2 should rollback.

    Is it possible? How it can be done?

  • This is a good start on the subject:

    Nesting Transactions

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Koen Verbeeck (8/8/2013)


    This is a good start on the subject:

    Nesting Transactions

    We tried to implement it.But if inner transaction gets commit first.I want inner transaction to roll backup if outer transaction gets failed(rollback).

    In coding we are using 'SqlConnection' object. So if you have any example let me know.

  • IT researcher (8/8/2013)


    Koen Verbeeck (8/8/2013)


    This is a good start on the subject:

    Nesting Transactions

    We tried to implement it.But if inner transaction gets commit first.I want inner transaction to roll backup if outer transaction gets failed(rollback).

    In coding we are using 'SqlConnection' object. So if you have any example let me know.

    The article has an example. If you nest transactions, the outer transaction will rollback the inner transaction.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Does nested transactions only supported in Transaction Statements(Transact-SQL ) ? In coding i am using 'sqlconnection' object. But inner transaction gets comited even though outer transaction fails

  • IT researcher (8/8/2013)


    Does nested transactions only supported in Transaction Statements(Transact-SQL ) ? In coding i am using 'sqlconnection' object. But inner transaction gets comited even though outer transaction fails

    Don't you send TSQL statements to the database over the sqlconnection?

    Maybe you should post your code.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply