Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


How do I 'mount' a SQL DB

Posted on 2008-11-07
Medium Priority
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

graye earned 1336 total points
ID: 22905283
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

tigin44 earned 664 total points
ID: 22905352
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

Author Comment

ID: 22905878
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 ??

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

LVL 26

Expert Comment

ID: 22907805
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

graye earned 1336 total points
ID: 22908024
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
ID: 23110757
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

581 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