Beginner's SQL: How do I find a detached database?

Viewed 19196

I'm brand new to SQL and I'm practicing some queries with a DB. I've now just detached the database using Tasks > Detach

Question 1: When I detach a file, I'm guessing it's saved to an MDF file? Where would I locate this file?

Question 2: When I create a new DB, where do the related files get saved? I'm assuming an MDF and an LDF set of files are created.

If it helps, here's my version info

Microsoft SQL Server 2008 (SP1) - 10.0.2531.0 (X64) Mar 29 2009 10:11:52 Copyright (c) 1988-2008 Microsoft Corporation Developer Edition (64-bit) on Windows NT 6.1 (Build 7601: Service Pack 1)

Thanks!

3 Answers

Ok so if you have already detached the database, and then realized that you are clueless where it is, you can do this trick.

  1. Expand server, then on Databases click Right Mouse then choose Attach...

  2. Click Add...

  3. Then in the new window that opens will be a path to the directory where your detached database is (if you haven't navigated from default location earlier)

Also, the default location for MSSql databases is:

C:\Program Files\Microsoft SQL Server\[YourSQLVersionGoesHere]\MSSQL\DATA

enter image description here

enter image description here

Hope this saves you some time.

Related