You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
--This example will restore the latest differential backup, and stop transaction logs at the specified date time. It will also only print the commands.
@HeadersSQL ASNVARCHAR(4000) =N'', --Dynamic insert into #Headers table (deals with varying results from RESTORE FILELISTONLY across different versions)
195
-
@MoveOption ASNVARCHAR(MAX)=N'', --If you need to move restored files to a different directory
207
+
@MoveOption ASNVARCHAR(MAX) =N'', --If you need to move restored files to a different directory
208
+
@LogRecoveryOption ASNVARCHAR(MAX) =N'', --Holds the option to cause logs to be restored in standby mode or with no recovery
196
209
@DatabaseLastLSN NUMERIC(25, 0), --redo_start_lsn of the current database
197
210
@i TINYINT=1, --Maintains loop to continue logs
198
211
@LogFirstLSN NUMERIC(25, 0), --Holds first LSN in log backup headers
@@ -350,6 +363,12 @@ IF (SELECT RIGHT(@MoveLogDrive, 1)) <> '\' --Has to end in a '\'
350
363
SET @MoveLogDrive +=N'\';
351
364
END;
352
365
366
+
/*Standby Undo File*/
367
+
IF (SELECTRIGHT(@StandbyUndoPath, 1)) <>'\'--Has to end in a '\'
368
+
BEGIN
369
+
RAISERROR('Fixing @StandbyUndoPath to add a "\"', 0, 1) WITHNOWAIT;
370
+
SET @StandbyUndoPath +=N'\';
371
+
END;
353
372
354
373
355
374
IF @RestoreDatabaseName ISNULL
@@ -366,7 +385,7 @@ IF @BackupPathFull IS NOT NULL
RAISERROR('@ContinueLogs set to 0', 0, 1) WITHNOWAIT;
537
556
538
557
SET @sql =N'RESTORE DATABASE '+ @RestoreDatabaseName +N' FROM DISK = '''+ @BackupPathFull + @LastFullBackup +N''' WITH NORECOVERY, REPLACE'+ @MoveOption +NCHAR(13);
539
-
558
+
540
559
IF @Debug =1
541
560
BEGIN
542
561
IF @sql ISNULLPRINT'@sql is NULL for RESTORE DATABASE: @BackupPathFull, @LastFullBackup, @MoveOption';
0 commit comments