Results 1 to 6 of 6

Thread: [RESOLVED] Restore MS SQL Databse from a backup file

  1. #1

    Thread Starter
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Resolved [RESOLVED] Restore MS SQL Databse from a backup file

    Hi everyone.
    I'm not much of a database designer but I need to know how can I restore an MS SQL Database from a backed-up file.

    Any help would be great. Thanks
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Restore MS SQL Databse from a backup file

    What version of SQL Server? 2000, 2005, SQL Express?

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Restore MS SQL Databse from a backup file

    2000 Sp3
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  4. #4
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Restore MS SQL Databse from a backup file

    You can do it in Query analyzer with commands like this:

    VB Code:
    1. BACKUP DATABASE Acctfiles
    2.    TO DISK = 'c:\ACS DESKTOP\Acctfiles_D18.bak'
    3. -- this does a backup
    4.  
    5. RESTORE FILELISTONLY
    6.    FROM DISK = 'c:\ACS DESKTOP\Acctfiles_D18.bak'
    7. -- this displays the "files" in the backup
    8.  
    9. RESTORE DATABASE Acctfiles_D18
    10.    FROM DISK = 'c:\ACS DESKTOP\Acctfiles_D18.bak'
    11.    WITH MOVE 'Acctfiles_data' TO 'c:\Program Files\Microsoft SQL Server\MSSQL\DATA\Acctfiles_D18.mdf',
    12.    MOVE 'Acctfiles_log' TO 'c:\Program Files\Microsoft SQL Server\MSSQL\DATA\Acctfiles_D18.ldf'
    13. -- this actually does a restore - you can restore to a different DB
    14. -- name and specify the data and log locations
    15. GO
    Are you restoring a DB from backup to correct a problem or to move a production DB to another SERVER?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  5. #5

    Thread Starter
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Restore MS SQL Databse from a backup file

    Moving to another server.
    Does it matter?
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  6. #6
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Restore MS SQL Databse from a backup file

    Quote Originally Posted by ComputerJy
    Moving to another server.
    Does it matter?
    Then the SQL I gave you should be sufficient - we use this type of script to move DB's all over the place - from server to server - customer to development - test DB names...

    The reason I asked is you should really "delete" the DB from the destination server before doing the RESTORE - you do not want to restore a DB into an existing DB - unless of course you are trying to recover from a production loss...

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

Posting Permissions

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



Click Here to Expand Forum to Full Width