• Hi Chris,

    The solution is supposed to apply the logs in NO RECOVERY mode so that more logs can be continuously applied automatically. The last step of actually bringing the database online is a manual one and has been purposefully kept so. My thought was that in normal circumstances the logs would be continuously applied. And in case of a disaster, the DBA would verify the entire environment and then decide to bring the standby DB online after stopping the DataMirror jobs.

    In order to bring your database online after all logs have been applied, you can consider adding the below statement just above the line which says "lblEndOfLoop:" which is the label for checking errors. That would be on line number 155.

    "RESTORE DATABASE @strDatabase WITH RECOVERY"

    So, immediately after looping through all logs and applying them, if you could add this line in the script, your database would get back online.

    One note though. Next time your DataMirror jobs run, the first database file to be applied needs to be a full backup and not a transaction log since your database would be online. So you may need to verify if this works with your setup.

    Also, if you are planning to connect and use the standby server actively and would have apps connecting through the day, you may run into a scenario where there are connections open when the next run of the DataMirror jobs start. You would then need a way to kill open connections to the DB. For that you may want to look at the following script from the Script library:

    http://www.sqlservercentral.com/scripts/Maintenance+and+Management/30024/

    Thanks,

    Girish