How to create SQL Agent job to automatically restore a database from latest backups? There are 3 different folders which store respectively full, differential, and log backups. Different types of backups occur in different schedules. Now I need to create a new job which will periodically restore the database in order to assure the consistency of the backups. There are some third party tools available but I do not want to use them. Now, I can't figure out how to specify in the Job Step script to choose the last full/dif/log backups from their folders? The thing is there are multiple files already in the folders.
Solution to the problem is described: 
https://www.mssqltips.com/sqlservertip/1584/auto-generate-sql-server-restore-script-from-backup-files-in-a-directory/