I am trying to copy a database from one folder to another. There is no program at all running except operating system.(I mean all windows shut)

I keep getting this :

The action cannot be completed because the file is open is another program


close file and try again

Try again, Try again , Try again .........

what the hell on earth is holding that file and how can I carry on with copy / delete / overwrite files(DB) as this problem is something very common.

Thanks

link|improve this question
feedback

migrated from stackoverflow.com Feb 10 '10 at 16:53

This question came from our site for professional and enthusiast programmers.

4 Answers

up vote 3 down vote accepted

Try net stop mssqlserver /y and see what happens. Naturally I'm assuming here it's okay to stop the DB server.

link|improve this answer
I think this is very likely going to be the resolution despite the tools suggested for checking what the file is being locked by. – tcnolan Feb 10 '10 at 23:27
feedback

Go to Task Manager and see, it's sqlservr.exe proccess is running. If so, kill it and try again. Also there is a useful small program called 'Unlocker' which allows to look which proccesses are attached to the file, kills them and let the file be deleted or moved.

A similar tool is WhoLockMe!

link|improve this answer
I've used those tools as well pretty good... – tcnolan Feb 10 '10 at 23:24
feedback

I usually prefer to use first party tools for this kind of thing, process monitor from sysinternals is my tool of choice for this kind of thing. Just watch out if you have a lot of background services running cause you will see lots of activity going through. Really useful for watching your registry as well.

http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx

link|improve this answer
feedback

Open the Microsoft SQL Server Management Studio,then open Object Explorer .Right Click and you can find Restart the connection.This will stop the SQL Server and you can delete or transfer the database.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.