How can I restore a database in an another server from .mdf and .ldf files

  • I don't have backup of the Database but I have .mdf and .ldf files. I want to restore the database in another server .

  • look up sp_attach_db

    ---------------------------------------------------------------------

  • Or, since sp_attach_db is deprecated on SQL 2005, CREATE DATABASE ... FOR ATTACH

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • you can use SSMS SQL Server Management studio to attach a database also by right on the Databases and then click ATTACH and then select files

    Regards,

    Syed Jahanzaib Bin Hassan

    MCTS | MCITP | OCA | OCP | OCE | SCJP | IBMCDBA

    My Blog

    http://www.aureus-salah.com

    Regards,
    Syed Jahanzaib Bin Hassan
    BSCS | MCTS | MCITP | OCA | OCP | OCE | SCJP | IBMCDBA

    My Blog
    www.aureus-salah.com

  • Attach is the best option, Use SSMS or T-SQL.

  • yes that pretty much what i do, dettach the DB , move the MDF, NDF and ldf files, then re-attach to the new location. i tend to script it when moving a few databases.

  • arun.sirpal (5/11/2011)


    yes that pretty much what i do, dettach the DB , move the MDF, NDF and ldf files, then re-attach to the new location. i tend to script it when moving a few databases.

    The only issue with that plan is that you can lose the db in the process (even if onle 1 byte is lost, the whole db is (possibly) gone).

    It's much safer to copy then attach. Once everything is fine, delete the uneeded copy.

Viewing 7 posts - 1 through 6 (of 6 total)

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