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 ). , , , .