I ran into a situation on my SQL Server 2005 test machine where I wanted to swap database files that were installed on two separate instances of SQL Server 2005. [One instance is the "default" instance, and one is named "Instance1".] The database files are located in a parallel file structure like so:
D:\SQLData\MSSQL
D:\SQLData\MSSQL$INSTANCE1
I figured the easiest way to accomplish this is to detach the databases from both servers, shutdown the SQL Services, swap the names of the two directories, startup the SQL Services, and reattach the databases. Upon reattaching the databases, I recieved a permissions failure ...
To fix this, I examined the file permissions of the data and log files. In my case, I needed both the local system account and the appropriate SQL Server user account corresponding to the SQL Server instance [in my case, the account is named SQLServer2005MSSQLUser$<machine_name>$<instance_name>] to have Full Control. [Swapping the names of the folders meant the data and log files permissions gave Full Control to the user associated with the other instance.]
All this assumes that the SQL Server instances run under the Local System account ...