Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2014-03-03
5
440 Views
Last Modified: 2014-03-03
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
Comment
Question by:feesu
  • 2
  • 2
5 Comments
 
LVL 10

Assisted Solution

by:HuaMinChen
HuaMinChen earned 500 total points
ID: 39899848
Try to stop all relevant services of relevant database instance within services.msc and then retry.
0
 

Author Comment

by:feesu
ID: 39899855
how do I do that?
0
 
LVL 10

Accepted Solution

by:
HuaMinChen earned 500 total points
ID: 39899866
run services.msc within the server machine
stop the services like what I show in the attached
retry to do detach
t674.png
0
 

Author Comment

by:feesu
ID: 39899898
Perfect. Thanks.
0
 
LVL 11

Expert Comment

by:Giladn
ID: 39899929
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question