Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How do I save my database as a .mdf?

Author  Topic 

spmchugh82
Starting Member

13 Posts

Posted - 2009-02-19 : 17:21:13
I am writing an ASP.NET application and I need a SQL Server .mdf file to act as my database. The table is already created... it is very simple. But I can't figure how how to do anything except save the solution.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-02-19 : 17:22:24
If the table is created, then it was created inside a database, which also means you have a data file which typically has MDF as the extension.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

spmchugh82
Starting Member

13 Posts

Posted - 2009-02-19 : 17:27:54
I know the table was created because I can save the solution and/or close SQL Server and open it back up and the table will be there. But I can't find the database file on my computer.
Go to Top of Page

spmchugh82
Starting Member

13 Posts

Posted - 2009-02-19 : 17:45:56
Can anyone answer this? Cause this seems like a real easy one for anyone that knows anythign about SQL Server to knock out of the park.

Why the hell cant I right click on my database and save it as a .mdf?
Go to Top of Page

SQLforGirls
Starting Member

48 Posts

Posted - 2009-02-19 : 18:02:29
Because that's not quite how the server works. You should already have an .MDF file which was created at the time you defined your database. If you did not specify the location of your Primary Filegroup when setting up the database, it most likely went to someplace like c:\mssql\data\dbname.mdf

Get out of the SQL Server Management Studio or wherever you're working. Go to the windows file system and search for [dbname].MDF. It's there.

Hope that helps.
Go to Top of Page

spmchugh82
Starting Member

13 Posts

Posted - 2009-02-19 : 18:21:42
AH!

Thank you SQLforGirls!

I had already spent some time looking through the file system but I did an advanced search for .mdf and it finally came up at C:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\Data

Man, that was quite the time waster.

Tara, thanks for suspending my post. That was very helpful and classy!
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-02-19 : 18:33:45
quote:
Originally posted by spmchugh82

Tara, thanks for suspending my post. That was very helpful and classy!



We need a forum emoticon that rolls its eyes!

As a moderator here, it is my responsibility to lock duplicate threads.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -