Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Cancelling Transaction
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Versions des environnements
SQL Server:
SQL Server 2014
Application:
Web
Divers
Thread ID:
01611676
Message ID:
01611681
Vues:
34
>I kind of like Nicholas idea, another alternative could be something like this:
>
>
>BEGIN TRY
>     BEGIN TRANSACTION
>         update MyTable1 set Field1 = @SomeValue where Field2 = @SomeValue2
>         IF @@ROWCOUNT > 0
>         BEGIN
>             update MyTable2 Set ....
>
>             insert into MyTable3 ....
>         END
>END TRY
>
>BEGIN CATCH
>      IF @@TRANCOUNT > 0
>          ROLLBACK
>END CATCH
>
>IF @@TRANCOUNT > 0
>          COMMIT
>
Thank you. Could you, please, clarify one thing. In your code, after CATCH/END CATCH, does the ROLLBACK automatically sets the @@TRANCOUNT to 0 (zero)? So that after ROLLBACK, COMMIT does not fire?
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform