Skip to content

Commit f68a84f

Browse files
committed
issue_1180: added @ForceSimpleRecovery
1 parent 5ae9cf2 commit f68a84f

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

sp_DatabaseRestore.sql

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ ALTER PROCEDURE [dbo].[sp_DatabaseRestore]
1616
@RestoreDiff BIT = 0,
1717
@ContinueLogs BIT = 0,
1818
@RunRecovery BIT = 0,
19+
@ForceSimpleRecovery BIT = 0,
1920
@StopAt NVARCHAR(14) = NULL,
2021
@OnlyLogsAfter NVARCHAR(14) = NULL,
2122
@Debug INT = 0,
@@ -865,7 +866,21 @@ IF @RunRecovery = 1
865866
IF @Debug IN (0, 1)
866867
EXECUTE sp_executesql @sql;
867868
END;
868-
869+
870+
-- ensure simple recovery model
871+
IF @ForceSimpleRecovery = 1
872+
BEGIN
873+
SET @sql = N'ALTER DATABASE ' + @RestoreDatabaseName + N' SET RECOVERY SIMPLE' + NCHAR(13);
874+
875+
IF @Debug = 1
876+
BEGIN
877+
IF @sql IS NULL PRINT '@sql is NULL for RESTORE DATABASE: @RestoreDatabaseName';
878+
PRINT @sql;
879+
END;
880+
881+
IF @Debug IN (0, 1)
882+
EXECUTE sp_executesql @sql;
883+
END;
869884

870885
--Run checkdb against this database
871886
IF @RunCheckDB = 1

0 commit comments

Comments
 (0)