Attach and Detach Method vs SQL Manage object method

  • Nusc

    SSCommitted

    Points: 1618

    Hi there,

    if you want to detach a database you would right click on the DB->Tasks->Detach

    What are the motivations behind doing this? I suspect if you want to make edits to an existing database and don't want to alter the production environment.

    What's the difference between attaching (right click on databases -> attach) and "restoring" a database (right click on DB->Restore DB)?

    Again, what are the motivations behind doing either one of these?

    When copying a database (Right click->Tasks->Copy Database0> Use the wizard) Then at some point you can choose between 'Use the detatch and attach method or use the SQL Manage object method.

    What is the motivation behind doing the above or using the wizard?

    • This topic was modified 1 month ago by  Nusc.
    • This topic was modified 1 month ago by  Nusc.
  • Site Owners

    SSC Guru

    Points: 80376

    Thanks for posting your issue and hopefully someone will answer soon.

    This is an automated bump to increase visibility of your question.

  • Michael L John

    One Orange Chip

    Points: 25929

    Nusc wrote:

    Hi there,

    if you want to detach a database you would right click on the DB->Tasks->Detach

    What are the motivations behind doing this? I suspect if you want to make edits to an existing database and don't want to alter the production environment.

    If a database is detached, you cannot modify the database.  One reason is to move or copy the database files from one place to another.  A few examples would be moving to a new server, a different set of disks, or to copy a production database to a testing environment.

    What's the difference between attaching (right click on databases -> attach) and "restoring" a database (right click on DB->Restore DB)?

    Again, what are the motivations behind doing either one of these?

    A restore requires a backup of the database, an attach requires the database files.  These are not interchangeable operations.

    You do have a backup and recovery process set up? If so, a restore would be to recover a database in the event of a failure, or a mistake.

    When copying a database (Right click->Tasks->Copy Database0> Use the wizard) Then at some point you can choose between 'Use the detatch and attach method or use the SQL Manage object method.

    What is the motivation behind doing the above or using the wizard?

    The wizard is at best, troublesome.  If you need to make a copy of a database, I suggest you take a backup, and restore it to the new location.  You could detach, copy, and attach, but that would require the database to be brought offline.

    Michael L John
    If you assassinate a DBA, would you pull a trigger?
    To properly post on a forum:
    http://www.sqlservercentral.com/articles/61537/

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

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