Skip to content

Commit 8eef506

Browse files
authored
Merge pull request BrentOzarULTD#1228 from ShawnCrocker/Issue_1198
Issue 1198 Bug: @StoPAt was ignored for full and diff
2 parents 3d094fc + ce097fd commit 8eef506

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
@@ -431,7 +431,9 @@ SELECT @LastFullBackup = MAX(BackupFile)
431431
FROM @FileList
432432
WHERE BackupFile LIKE N'%.bak'
433433
AND
434-
BackupFile LIKE N'%' + @Database + N'%';
434+
BackupFile LIKE N'%' + @Database + N'%'
435+
AND
436+
(@StopAt IS NULL OR REPLACE(LEFT(RIGHT(BackupFile, 19), 15),'_','') <= @StopAt);
435437

436438
IF @Debug = 1
437439
BEGIN
@@ -649,7 +651,9 @@ SELECT @LastDiffBackup = MAX(BackupFile)
649651
FROM @FileList
650652
WHERE BackupFile LIKE N'%.bak'
651653
AND
652-
BackupFile LIKE N'%' + @Database + '%';
654+
BackupFile LIKE N'%' + @Database + '%'
655+
AND
656+
(@StopAt IS NULL OR REPLACE(LEFT(RIGHT(BackupFile, 19), 15),'_','') <= @StopAt);
653657

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

0 commit comments

Comments
 (0)