use master
go
declare @databaseName varchar(50), @backupFileName varchar(100), @restoreDirectory varchar(100)
— Set the name of the database to restore
set @databaseName = ‘database’
— Set the path to the directory containing the database backup
set @restoreDirectory = ‘pathBackupsfolder’
— Create the backup file name based on the restore directory, the database name and today’s date
set @backupFileName = @restoreDirectory + @databaseName + ‘_’ + replace(convert(varchar, getdate(), 112), ‘-‘, ‘.’) +’0000’+ ‘.bak’
RESTORE DATABASE database FROM DISK = @backupFileName WITH NORECOVERY, REPLACE