I have a database file .mdf
from MS SQL EXPRESS in folder:
C:\\Program Files\\Microsoft SQL Server\\MSSQL10.SQLEXPRESS\\MSSQL\\DATA
As other suggested running as administrator will help.
However this only if the windows user is actually an admisnitrator on the machine which sql server runs.
For example when using SSMS from a remote machine it will not help using "run as administartor" if the user is only a administrator on the machine runing SSMS but not on the machine running SQL Server.
If you are already running as an adminstrator, make sure the user you are using has the proper server roles.
In my case, Run as Administrator does not help. I solved the problem by changing the Build-in Account to Local System in Configuration Manager.
My solution was slightly more complicated. After verifying the user the service was running as, running MSSMS as local and domain administrator, and checking folder permissions, I was still getting this error. My solution?
Folder ownership was still maintained by local account.
Properties > Security > Advanced > Owner > (domain/local user/group SQL services are running as)
This resolved the issue for me.
Here is what happened in my case. I was asked to attach files for a database. I was given the file names as follows
I proceeded to attach the files and kept getting the files are in use by another process.
I ran a query against the system view select name, physical_name from sys.master_files; and saw that the exact file names were already in use by another database, thus each time I tried to attach the files, I kept getting the error the files are in use by another process(sql server)
Thus if you are getting such a message, then also query against the system view sys.master_files and see which database may already be using the same name files. Hereafter you will figure out what to do.
thanks.
I had the same problem. After several tries, I realized that connecting the sql server with windows authentication resolved the issue.