Home Forums SQL Server 7,2000 T-SQL Nested transactions in nested sprocs- possible? RE: Nested transactions in nested sprocs- possible?

  • The answer to your last question is yes. Commit and Rollback are alternative ways of closing a transaction. Once you have rolled back (or committed) a transaction, there is of course no transaction outstanding. So if you issue the 'COMMIT' command, SQL Server will protest that there is nothing to commit.

    In the case of the savepoint, the transaction is not closed. So you can still issue simple rollback or commit commands (but not both!) against the transaction.

    A note of caution, though - long transactions are likely to cause blocks and possibly deadlocks, which could degrade performance significantly. This is especially true if you have the transaction isolation level set to "SERIALIZABLE" (or include HOLDLOCK hints) - as you probably should for penny-perfect financial data.

    It sounds as though you should be reading all the data into work tables first in a transaction, then processing the data, then inserting the rows into your invoice table. (You may not ven need to use a transaction for this insert, depending on whether other processes are likely to be updating the same tables.)

    Tim Wilkinson

    "If it doesn't work in practice, you're using the wrong theory"
    - Immanuel Kant