Results 1 to 9 of 9
  1. #1
    Join Date
    Sep 2009
    Posts
    21

    Unanswered: Is there a way to go back and restore a table?

    Basically I ran an update statement that filled in all the null values of my table to an incorrect value......

    Is there a way to roll back that update statement? maybe?

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    BEGIN TRAN

    UPDATE <myTable> SET Col = 'Value'

    ROLLBACK


    Do this in the future and just highlight the BEGIN and UPADTE

    My guess is that's not what you've done

    Do you have a backup?

    Also, I do this

    SELECT * INTO <mytable_bkp> FROM <myTable>

    So you have the original data

    Good learning experience...how big was the table?
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Sep 2009
    Posts
    21
    1 million rows....

    should have made a backup table

    though not sure what the begin tran and rollback would have done, unless I throw in a select statement before the rollback to see the changes made....if that actually works...
    Last edited by fff398; 11-04-09 at 11:48.

  4. #4
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    do you have a backup of the database?
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  5. #5
    Join Date
    Sep 2009
    Posts
    21
    :P the backup is about 2 months old...gotta rerun alot of scripts to bring it up to speed

  6. #6
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Quote Originally Posted by fff398 View Post
    though not sure what the begin tran and rollback would have done, unless I throw in a select statement before the rollback to see the changes made....if that actually works...
    Then add a select statement between the UPDATE and the ROLLBACK!
    George
    Home | Blog

  7. #7
    Join Date
    Jun 2004
    Location
    Long Island
    Posts
    696
    and fire the DBA

  8. #8
    Join Date
    Jan 2004
    Location
    In a large office with bad lighting
    Posts
    1,040
    Quote Originally Posted by PMASchmed View Post
    and fire the DBA
    A good DBA would already have a current backup. My guess is that the OP is a developer who has his own personal database and has been slack on keeping it backed up.

    If I am wrong, then I will echo PMA. Even development databases need to be backed up regularly. Once a day, or once a week at a minimum.

    -- This is all just a Figment of my Imagination --

  9. #9
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Quote Originally Posted by tomh53 View Post
    A good DBA would already have a current backup.
    ANY DBA

    I would say they're not
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •