SQL Server Locked Data Files

I have a SQL Server database where I have data and log files stored on an external USB drive. I switch an external drive between my main development machine in my office and laptop when not in my office. I am trying to use sp_detach_db and sp_attach_db when moving between desktops and laptops. I find that this works fine on the desktop - I can detach and reconnect the database there is no problem. But on the laptop, I can’t reconnect the database (the database was originally created on the laptop, and there was the first gap). When I try to connect to a laptop, I get the following error:

Cannot open the physical file "p: \ SQLData \ AppManager.mdf". Operating system error 5: "5 (no error found)"

I find many references to this error, stating that this is a permission issue. So I went this route and made sure that the SQL Server service account has the appropriate permissions. I also created a new database on the same path and was able to successfully detach it and reconnect. Therefore, I am sure that permissions are not a problem.

Further research shows that I cannot rename, copy, or move data files because Windows considers them to be locked - even when the SQL Server service is stopped. No process to lock files was detected in Process Explorer.

How to find out what blocks files and unlock them.

, SSMS, SQL Server - , .

18/09/2008

. . :

  • , , , - , , - " ",
  • , , - .
  • , , , - Process Explorer Unlocker, , .

NB. SQL Server, - .

, , , - , , . , , (1 ). , , , .

+3
9

, , perms //? , SQL Server 2005 , (, , , , SQL Server), . , MDF LDF, . . onupdatecascade.com

+4

? , . , - , , , .

?

: , - . Unlocker, , . .

+1

Enterprise Manager SSMS, , ? . , mdf - . , , , .

0

, , . , .

0

sqlservr.exe /c , . , .

(.ldf). , - / , .

0

. , , - , SQL .. ProcMon ProcessExplorer , - "" .

, , .

PS. USB, TrueCrypt- ( , " " )

0

SQL Server SQL Server. SQL Server , " " ​​- " :". , , , . , - , , .

0

I solved a similar problem by giving the system administrator all permissions:

  • right click> properties
  • security tab
  • in group or usernamesclick "Edit."
  • click add> advanced
  • Click find nowto view all available permissions.
  • select an administrator and add him to the list.
  • give him full permission.
0
source

Source: https://habr.com/ru/post/1697005/


All Articles