USE of with ROLLBACK

  • hello comunty

    If i run an UPDATE TSQL command , i want to know using ROLLBACK ,after running this Update i can

    run the update to see the result and if they don´t correct i can make a rollback.

    If possible , give me a very simple example.

    Many thanks

    Luis Santos

  • ROLLBACK is one of the possible "mates" to BEGIN TRANS. The other is COMMIT.

    Given what you're talking about, it would simply be something like this:

    BEGIN TRAN

    Update my table

    set etc....

    simply run that, and then check to see if you like the changes or not. If you like the changes, then issue the COMMIT command; if you don't want them, then issue ROLLBACK. Just remember that you have to do one or the other.

    Please note that you would likely need to look at the changes using a locking hint allowing you to see the uncommitted results, as in (READ UNCOMMITTED) or NOLOCK.

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

Viewing 2 posts - 1 through 1 (of 1 total)

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