How do I 'mount' a SQL DB

Posted on 2008-11-07
Last Modified: 2012-05-05
Hi, I've just completed a SQL 2005 installation, and I need to remove any databases that are not going to get used (like model?), and additionally 'mount' a databases that is stored on another drive..

How can I achieve this ?
Question by:j4jack
    LVL 41

    Accepted Solution

    Oooh, kinky :)
    The model is considered a "system database" and should not be removed.   You might have some demo databases (Pubs, Northwind, etc) that you can safely remove.
    The method to move database files (the *.mdf and *.ldf files) is by doing an Attach operation.  This can be easily done via the SQL Management Studio... just right click on databases, actions, attach.
    LVL 26

    Assisted Solution

    master, model, msdb and tempdb are system databases and you shouldnt remove them...
    by the way you can add an existing database by using sp_attach_db procedure or by using aterprise manager...
    right click on the databases entry and choose attach ...
    in the window opened choose the db files form file system and press OK...
    thats all
    LVL 1

    Author Comment

    OOPS ! Bit of a problem... I originally on Machine 'A' went into SQL, right clicked on the database, then choose Tasks, Backup, Full and picked a location on the C drive.

    Copied this file over to machine 'B', and have tried to go attach and it give me an error saying the the database is not the primary database file , error 5171.....did I do the backup incorrectly ??

    LVL 26

    Expert Comment

    did you restore the bakuped file..
    sql databases basicly consist of two files with the extensions .mdf and .ldf .
    You can attach these files as database files... check that...
    LVL 41

    Assisted Solution

    You basically have two options... (er, well maybe 3)
    • Perform a backup and restore operation to move the database
    • Perform a detatch/attach operation
    • Use the copy database wizard
    So, it looks like you did a backup, and file is probably a *.bak file.   You'd use the SQL Management Studio to create a new database and perform the restore operation
    LVL 51

    Expert Comment

    by:Mark Wills
    No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

    I will leave the following recommendation for this question in the Cleanup topic area:
       Split: graye {http:#22905283} & tigin44 {http:#22905352} & graye {http:#22908024}

    Any objections should be posted here in the next 4 days. After that time, the question will be closed.

    EE Cleanup Volunteer

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
    So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now