If you have multiple backup database backups on a single SQL Server 2008 R2 backup device, this script will help you restore a database from the LATEST full and differential backups residing on that backup device.
If this script is to be used for restoring a SQL Server 2005 database, please remove "CompressedBackupSize" from the CREATE temporary table statement.
The following page contains a stored proc script for restoring all databases from a number of backup files:
http://www.karaszi.com/SQLServer/util_restore_all_in_file.asp
I used information on the above page in constructing my "CREATE TABLE #RestoreHeaderOnlyData" script.