I moved database files as follows:
Alter database xyz set offline;
-- I then physically moved the files
Alter database xyz
Modify file
(Name = xyz_logical_name,
Filename = 'D:\data\xyz.mdf')
Alter database xyz
Modify file
(Name = xyz_log,
Filename = 'D:\log\xyz_log.ldf')
Alter database xyz set online;
The database came online successfully.
However, on rebooting the host server (for another reason), I found the databases had disappeared eventhough the physical files were still in place.
I then tried to attach them using SSMS but got an error :
CREATE FILE encountered operating system error 5(Access is denied) while attempting to open or create the physical file 'D:\data\xyz.mdf'. (MSS, Error:5123)
Both my user account and the SQL Server service account have full access on the D drive.
Am I missing something please?