SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2007
    Location
    Australia
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Restoring Just 1 Table from a .BAK file

    Hey,

    I have a MS SQL 2005 database, however one of the tables has old data in it which I want replaced.

    I have a .BAK file that was created a week ago, which has the correct data in this particular table, and I want the data from this table in the BAK file to replace the same table in the current database.

    I cant just do a full table because there is other information in other tables in the BAK file which is old.

    How can I do this? I am thinking if I could just export then import the data from this table, but dont know how to do this. I am used to MYSQL, and know this can be done easily using phpmyadmin.

    Any help would be great.

  2. #2
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,638
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    What you want to do is restore that backup to a separate database, then you can use Sql Server Management Studio to "import" the data and wipe out the other table.

    Note that if there are foreign keys referencing things, then it could get dicey. Backup everything before beginning.

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2007
    Location
    Australia
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for the reply.

    OK so I have loaded the BAK file into a seperate database, but am unsure how to go on from there.

    In visual studio express when I right click on the table i can see some options but nothing that allows my to update the table.

    I went into the old database that I just loaded from the BAK file, right clicked on the table I want to copy, clicked open, and then selected all and press copied, but then when I logged out and into the correct database and tried to do the same but paste the data over the top it would let me. I think down the bottom it was saying read only.

    Can anyone give me some steps to follow? Thanks.

  4. #4
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,638
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Do you have Sql Server Management Studio? That will work alot better. What you want to do is use the import data option then follow the prompts, making sure to go advanced and choose the "overwrite data" option.

    Now, this still may not work as there might be constraints and such involved. We don't know enough about the specific database to tackle that one.


Bookmarks

Posting Permissions

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