0

I am developing a software with vb.net 2010 and sql server 2008 R2. While developing with my laptop where sql server is running every thing is ok, but when I want to deliver the project to the customer I must install sql server R2 to customer machine. How to get my database .mdf format to use it with my project. Thankyou

2 Answers 2

1

You need to detach the mdf file from your computer and then copy that file to your storage device of your choice say a USB. Afterwards if there is already an installed SQL server in your client you could copy the mdf file that you detach and then attach that mdf file this time.

To Detach:

  • Right Click on the Database that you want to Detach then Task --> Detach

enter image description here

To Attach:

  • Right Click on the word Databases then Attach

enter image description here

Don't forget of course to Attach again in your own computer the Database that you detached earlier.

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

3 Comments

This is fine, but will this deletes the database from the my computer? You said I will need to attach again the database!
@alrajhi20 No it will not delete your file. You could not copy an mdf file unless it is detach and you could not use it again unless it is attached back.
Can I use this .mdf database for my softwares? Instead of attaching them again in my sql server? I mean as a local database than server database?
1

Just make a backup of your database and restore it on the client's machine.

You can do this either with Visual Studio:

...or with T-SQL:

Detaching and attaching the database (as described in the other answer) is possible too, but the recommended way is making a backup.
Plus, if you are running at least SQL Server 2008 R2 Standard Edition on your laptop, you can use SQL Server's built-in backup compression, which will significantly reduce the size of the backup file (compared to the regular database size).

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.