4

I have a database which is sitting on my local PC. I want to create a .mdf file based on this database. I created an empty .mdf file in Visual Studio. How to connect SQL Server Management Studio and run queries against it?

But I want to create .mdf file based on existing database which will save me time on rebuilding whole DB in Visual Studio and also it will have all of the data in tables.

I check this link. it is not helping me solve my question.

Also was trying to copy .mdf file from C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA into my project in App_Data folder but it trowing error cannot complete because file is used by SQL Server
Thank you.

4
  • 1
    is it a big database? Before copying, make shure database connections are closed (alse close visual studio) Commented Aug 15, 2013 at 5:33
  • yes DB is big more that 100K records. I just stop db in Management studio after that i was able to copy it in App_Data folder in my project Commented Aug 15, 2013 at 18:05
  • 2
    possible duplicate of SQL - How to backup a database and export as a MDF file with MS SQL 2008 R2 Commented Dec 16, 2013 at 10:30
  • 3
    This question has been answered: stackoverflow.com/questions/3971727/… Commented Dec 16, 2013 at 10:30

1 Answer 1

1

First close all the programs and then stop the SQL SERVER AGENT. You should now be able to copy the .mdf file. After copying the files, don't forget to start the SQL SERVER AGENT.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.