Skip to content

Commit ce097fd

Browse files
committed
Issue 1198 Fix @StoPAt for Full and Diff
1 parent f7d6c81 commit ce097fd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

sp_DatabaseRestore.sql

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,9 @@ SELECT @LastFullBackup = MAX(BackupFile)
420420
FROM @FileList
421421
WHERE BackupFile LIKE N'%.bak'
422422
AND
423-
BackupFile LIKE N'%' + @Database + N'%';
423+
BackupFile LIKE N'%' + @Database + N'%'
424+
AND
425+
(@StopAt IS NULL OR REPLACE(LEFT(RIGHT(BackupFile, 19), 15),'_','') <= @StopAt);
424426

425427
IF @Debug = 1
426428
BEGIN
@@ -638,7 +640,9 @@ SELECT @LastDiffBackup = MAX(BackupFile)
638640
FROM @FileList
639641
WHERE BackupFile LIKE N'%.bak'
640642
AND
641-
BackupFile LIKE N'%' + @Database + '%';
643+
BackupFile LIKE N'%' + @Database + '%'
644+
AND
645+
(@StopAt IS NULL OR REPLACE(LEFT(RIGHT(BackupFile, 19), 15),'_','') <= @StopAt);
642646

643647
--set the @BackupDateTime so that it can be used for comparisons
644648
SET @BackupDateTime = REPLACE(@BackupDateTime, '_', '');

0 commit comments

Comments
 (0)