First, itโs best to back up and restore, rather than disconnect and attach.
Secondly, most likely, the session that you use to configure the database on SINGLE_USER is the one that still occurs when you try to start recovery (since you use the graphical interface, it connects to its own session so that it cannot receive access).
Either perform the recovery as a text command, or switch the query window to use another database, such as master, first. Or you can simply close the request window so that it is no longer connected.
You can always check who is associated with select * from master.dbo.sysprocesses .
Update
Assuming that the database that you want to restore already exists, and if there is one backup file on the disk (it does not have several backups), there is no need to restore the log files after restoring a full backup, and then restore via script super Super easy:
RESTORE DATABASE DBName FROM DISK = 'C:\path\DBNameBackup.bak';
Learning this syntax will make your life easier, because when you set SINGLE_USER, you are already in the only session that is connected. In addition, I find that typing the restore command is faster than using the GUI, and I like the control I have. Repetition of this ultimately cements it in your mind, and you no longer need to look for syntax.
It is not even that difficult to recover log files. Just one thing to remember, WITH NORECOVERY :
RESTORE DATABASE DBName FROM DISK = 'C:\path\DBNameBackup.bak' WITH NORECOVERY; RESTORE LOG DBName FROM DISK = 'C:\path\DBNameBackup1.log' WITH NORECOVERY; RESTORE LOG DBName FROM DISK = 'C:\path\DBNameBackup2.log' WITH NORECOVERY; RESTORE LOG DBName FROM DISK = 'C:\path\DBNameBackup3.log' WITH NORECOVERY; ... 4 5 6 7 and so on RESTORE LOG DBName FROM DISK = 'C:\path\DBNameBackupX.log' WITH RECOVERY;
There ... you very easily restored your log files. You can even restore the exact point in time using WITH STOPAT ! Also, if you forget and accidentally send the last expression about restoring the WITH NORECOVERY , you simply issue RESTORE DATABASE DBName WITH RECOVERY; to complete the final steps to make the database useful (rollback of pending transactions, etc.).