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

I tried to copy a file from "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\db.mdf" to a different place.

But a message pop out

Cannot copy db: It is being used by another person or program.
Close any programs that might be using the file and try again.
I restarted the machine but still got it. Nobody use the file except me.

Why? Thank you .
Posted

This is database file.Several SQL server services used it.That's why error occured.
You can copy file after one of below
1=>Detach database using SQL Server Mgmt Studio->copy file->attach it again

2=>Run->CMD->Services.msc
->stop sql server services -> and copy data file desired location-> start services.
 
Share this answer
 
v2
Hi,

You can not just copy a mdf file just by selectng copy and paste :). You need to detach the file from the database ( so the database would be offline) once the database file is detached then only you can copy to another location.

System does not allow you to copy as your database file(.mdf) is being used by database server for any database transaction.
 
Share this answer
 

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