I think I am having some confusion over 'Attach' and 'Attach_Rebuild_log' clauses : BOL says
" In contrast, for a read-only database, the log cannot be rebuilt because the primary file cannot be updated. Therefore, when you attach a read-only database with a log that is unavailable, you must provide the log files, or the files in the FOR ATTACH clause." refer http://msdn.microsoft.com/en-us/library/ms176061.aspx
So, It basically says that for a read/write database, even using 'for Attach' clause would rebuild the log but for read only database, we have to provide Log File details.
But if I try this,it works fine not sure what I am missing.
1.Create database Test
2.Alter Database test set read_only
3. deatach the database
4.-- Delete the log file
5.Create Database Test ON (FileName='E:\Data\Backup.mdf') For Attach;-- you can attach the database fine. .
The only difference between Attach and Attach_rebuild_log,I could see\test is attach clause does not work when there are multiple unavaible log files you have to use Attach_rebuild_log.
Also, For Attach_Rebuild_log, it says, this works for READ\WRITE databases only. BOL QUOTE : Specifies that the database is created by attaching an existing set of operating system files. This option is limited to read/write databases.
I tired the above using Attach_rebuild_log and it worked. Looks like I am missing something here. Please let me know.
Hope it Helps!!