Just a quick comment on the process, not the query...
Unless you've taken the full backup WITH CHECKSUM, the verifyonly verifies very little of the backup and can easily verify as valid a backup that won't restore. If you're going to depend on RESTORE VERIFYONLY, you need to ensure that all the backups are taken WITH CHECKSUM, even then it's not 100% certain.
If you are using a Maintenance Plan, there is no option to set the WITH CHECKSUM option on for backups.
SQL Server Books Online (SQL Server 2008 R2) says the following under the BACKUP topic:http://msdn.microsoft.com/en-us/library/ms186865(v=sql.105).aspx"...
Enables backup checksums, so that BACKUP can do the following:
1. Prior to writing a page to the backup media, BACKUP verifies the page (page checksum or torn page), if this information is present on the page.
2. Regardless of whether page checksums are present, BACKUP generates a separate backup checksum for the backup streams. Restore operations can optionally use the backup checksum to validate that the backup is not corrupted. The backup checksum is stored on the backup media, not on the database pages. The backup checksum can optionally be used at restore time,
Using backup checksums may affect workload and backup throughput.
This is the default behavior for a compressed backup.
However, when I run RESTORE HEADERONLY for a compressed backup made with a maintenance plan, the HasBackupChecksums column has a value of 0, which indicates the backup does not have checksums. I guess the Maintenance Plan is explicitly setting the NO_CHECKSUM option. Or Books Online is wrong.
I just looked at a compressed backup that I was made with an explicit backup command, and the RESTORE HEADERONLY HasBackupChecksums column had a value of 0.
When I added the CHECKSUM option to the backup command, the RESTORE HEADERONLY HasBackupChecksums column had a value of 1.
It appears that SQL Server 2008 R2 Books Online is incorrect about CHECKSUM being the default for compressed backups.