I was trying to move a database (.mdf and .ldf files) to a different directory on the same server hosting the SQL server. I followed these steps found in this Q&A:
ALTER DATABASE MyDB SET SINGLE_USER WITH ROLLBACK IMMEDIATEALTER DATABASE MyDB SET OFFLINEALTER DATABASE MyDB MODIFY FILE (Name = MyDB, Filename = 'N:\DATA\MyDB.MDF')ALTER DATABASE MyDB SET ONLINEALTER DATABASE MyDB SET MULTI_USER
When I got to Step4, I got "Access Denied". Unfortunately, my maintenance windows were very short and no time to troubleshoot. So I decided to drop the database and restored it using the WITH MOVE clause to place the DB files in the right directory. No issue.
My question is why did I get "Access Denied"? I didn't change MSSQL service account. It's the same account that ran the RESTORE.