Click here to Skip to main content
15,357,967 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I have database at location C:\DB\Detail.mdf. The database is MsSql. I am using that Detail Database in one application. While that application is running i try to copy a database to new location as a extra copy (eg.E:\DB). But it is showing as that the database is using by another application. I try'd manually and also in coding. But its not working. Is there any way to do this. If know please tell me.

The shortest way is to make a local backup, copy the .bak file to remote machine and make a restore there...

Can be done with sql managemant studio

Can also be made in code!
Mehdi Gholam 11-Oct-11 2:22am
My 5!
Stop the SQL Server (MSSQLSERVER) service and copy the mdf and ldf files. After pasting another location, start the service.
You can not copy the database while it is running. either you need to take it OFFLine or detach it to copy.

Offline by Query
ALTER DATABASE databasename SET Offline

make it offline and then copy.

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