Resolve File Access Denied Error In SQL Server

Sometimes we are required to copy the database files(.mdf, .ldf) from SQL Server root directory to another directory or disk. Then SQL Server throws an error that "The Action can't be completed because the file is open in SQL Server(MSSQLSERVER)."

This error occurs because an instance of SQL Server is running , before trying to copy the database files we need to stop the sql server instance. To stop the SQL Server instance first right click on your Server name in SQL Server.


And by clicking on Stop option, this option stops the current runing SQL Server instance.

You can see that SQL Server instance has been stoped.


Now you can copy the files without any error. After copying the files don't forget to Start the SQL Server instance or else other SQL Servers will not work.


Now your SQL Server will work in its previous state.