Suddenly cannot access SQL Server database My SQL Server 2008 R2 database suddenly cannot be accessed. When I try to view it in SQL Server Management Studio, it appears something like below:



It cannot be detached and attached. I need to 'Take Offline' and then 'Bring Online' to solve it. This problem happens around once a week. 

After checking the error logs, the following are the records:


  Error: 18456 Severity: 14 State: 38.
  FCB::Open failed: Could not open file C:\Program Files (x86)\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\PWRCMS.mdf for file number 1.
  OS error: 32(The process cannot access the file because it is being used by another process.).
  Error: 17204 Severity: 16 State: 1.
  Starting up database 'PWRCMS'.
  Login failed for user 'sa'.
  Reason: Failed to open the explicitly specified database. [CLIENT: 172.16.7.68]
  Error: 18456 Severity: 14 State: 38.
  Login failed for user 'sa'.
  Reason: Failed to open the explicitly specified database. [CLIENT: 172.16.7.68]
  Error: 18456 Severity: 14 State: 38.
  FCB::Open failed: Could not open file C:\Program Files (x86)\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\PWLCMS.mdf for file number 1.
  OS error: 32(The process cannot access the file because it is being used by another process.).
  Error: 17204 Severity: 16 State: 1.
  Starting up database 'PWRCMS'.
  Starting up database 'PWLCMS'.


Is there any solution to prevent this happening?
Unknown,FCB::Open failed: Could not open file C:\Program Files (x86)\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\PWRCMS.mdf for file number 1.  OS error: 32(The process cannot access the file because it is being used by another process.).


Your database is in use from another process. You need to identify what that process is. Perhaps you attach the DB with AttachDatabase connection string option to a different SQL Server Express instance?