OK, if you need to schedule it, you something which is fully automated. As I said, I only need to do this ad-hoc.
Here is a script, but it will probably need some fine-tuning. For one thing, where I sit at home, I don't have a set up of backups to test on. But it should get you started. Please consult the documentation for the tables backupset and backupfile as well as the documentation for the RESTORE statement for details.
DECLARE @fullbackup numeric(25,0),
@filename nvarchar(260),
@cur CURSOR,
@stoptime datetime2(3) = dateadd(HOUR, 10,
convert(datetime2, convert(date, sysdatetime())))
\-- Restore full backup.
SELECT TOP (1) @fullbackup = s.last_lsn,
@filename = f.physical_name
FROM msdb.dbo.backupset s
JOIN msdb.dbo.backupfile f ON s.backup_set_id = f.backup_set_id
WHERE s.database_name = 'yourdb'
AND s.backup_finish_date < @stoptime
AND s.type = 'D'
ORDER BY s.backup_finish_date DESC
RESTORE DATABASE yourdb FROM DISK = @filename WITH NORECOVERY
\-- Get all intermediate log backups.
SET @cur = CURSOR STATIC FOR
SELECT f.physical_name
FROM msdb.dbo.backupset s
JOIN msdb.dbo.backupfile f ON s.backup_set_id = f.backup_set_id
WHERE s.database_name = 'yourdb'
AND s.type = 'L'
AND s.last_lsn > @fullbackup
AND s.backup_start_date < @stoptime
ORDER BY s.last_lsn
OPEN @cur
WHILE 1 = 1
BEGIN
FETCH @cur INTO @filename
IF @@fetch_status <> 0
BREAK
RESTORE LOG yourdn FROM @filename WITH NORECOVERY
END
\-- Find the last log
SELECT TOP (1) @filename = f.physical_name
FROM msdb.dbo.backupset s
JOIN msdb.dbo.backupfile f ON s.backup_set_id = f.backup_set_id
WHERE s.database_name = 'yourdb'
AND s.type = 'L'
AND s.backup_start_date > @stoptime
ORDER BY s.backup_start_date ASC
RESTORE LOG yourdb FROM @filename WITH RECOVERY, STOPAT = @stoptime