Click here to Skip to main content
15,895,283 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Sounds silly I know, but I created a database in MSSMS, filled it with data and now can not find it anywhere. I can open it in MSSMS, do anything I want to it but can not find it anywhere on my computer. I have used Explorer with many configurations and it can't find it. I even searched using just '*.mdf' still didn't find my file, I've manually looked everywhere I can think of with no luck.

Does anybody have any idea Where oh where has my .mdf gone?

darby
"When you were born, you cried and the world rejoiced.
Live your live so that when you die
the world cries and you rejoice!"
~Old Indian Proverb~

What I have tried:

Manual searches, and Windows Explorer using many different search criteria
Posted
Updated 27-Aug-18 5:40am

1 solution

Open SSMS, and right click the main server name node in the "Object Explorer" pane.
Select "Properties", and in the resulting dialog select the "Database Settings" page from the list on the left.
Near the bottom is the "Database default locations": the "Data" box gives the folder where SQL Server stores its database files.
 
Share this answer
 
Comments
Member 10376725 27-Aug-18 11:52am    
Thank you, I found it. I wonder why Explorer didn't find it.
OriginalGriff 27-Aug-18 12:01pm    
Possibly because it's not "yours" - it's owned by the agent user that runs SQL Server, not by the user you log in as.
Member 10376725 27-Aug-18 13:21pm    
That needs some explaining. Anyway, it did bring up another problem, when I tried to attach the database to a VB project it said I don't have permission to use the file. So, I changed the permissions to allow everyone access and now it tells me the file is open in another program. For the life of me I have no idea what it is talking about.
Member 10376725 27-Aug-18 13:22pm    
Who is the agent if not me, I'm the only one that uses this computer and installed everything myself.
OriginalGriff 27-Aug-18 14:21pm    
Oh boy ... :laugh:

You don't "own" your computer, not any more - the OS does, and it decides what you are allowed access to. You aren't the only user, not by a long shot, and most of the "not you" users are for things like Services - which because they run before you log in cannot run under your user ID. And SQL Server is a service, which runs under its own agent ID.

Try this: run Task Manager (CTRL + SHIFT + ESC will get you there), make sure you are in "more details" mode (if it says "Fewer details" in the bottom left, you are), and click the "Details" tab. You see a column "User Name", which will contain you, SYSTEM, and a bunch of other names, who are also users but who can't really log in.

SQL Server runs under its own user(s), probably "LOCAL SERVICE" and "MSSQL$" plus the instance name. That's the user that "owns" the databases, not you! And it's for good reasons: firstly so that it can act as a service to other computers, even if you don't log in this week; and second so it can "grab" the database files to prevent anyone else from messing about with them. Once you give SQL a database, it doesn't like to let go! :laugh:

Why are you trying to find the actual files?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900