• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 487
  • Last Modified:

SQL Server 2005 - MDF File is In Use (Permission Denied)

Hi experts,

I have this SQL Server 2005 database that even when I deattach it or take it offline I am not able to copy it or deal with it as it keeps saying “database is in use” and “permission denied”. I have restarted my PC but it keeps saying the same. I don’t know how to deal with it!

Thanks,
0
feesu
Asked:
feesu
  • 2
  • 2
2 Solutions
 
HuaMinChenBusiness AnalystCommented:
Try to stop all relevant services of relevant database instance within services.msc and then retry.
0
 
feesuAuthor Commented:
how do I do that?
0
 
HuaMinChenBusiness AnalystCommented:
run services.msc within the server machine
stop the services like what I show in the attached
retry to do detach
t674.png
0
 
feesuAuthor Commented:
Perfect. Thanks.
0
 
GiladnCommented:
If all the above fails, try setting the database to SINGLE USER MODE
with the following syntax:
USE [master];
GO
ALTER DATABASE  database-name  SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
GO

don't forget to set single user to false when done, see here:
http://technet.microsoft.com/en-us/library/ms345598.aspx

hope this helps,


G
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now