Skip to content

Commit c5e2734

Browse files
committed
Update sp_DatabaseRestore.sql
Add VerifyRestoreWithStoredProcedure option to sp_databaseRestore.
1 parent 4a09e00 commit c5e2734

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

sp_DatabaseRestore.sql

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ ALTER PROCEDURE [dbo].[sp_DatabaseRestore]
3939
@Version VARCHAR(30) = NULL OUTPUT,
4040
@VersionDate DATETIME = NULL OUTPUT,
4141
@VersionCheckMode BIT = 0,
42-
@FileNamePrefix NVARCHAR(260) = NULL
42+
@FileNamePrefix NVARCHAR(260) = NULL,
43+
@VerifyRestoreWithStoredProcedure NVARCHAR(260) = NULL
4344
AS
4445
SET NOCOUNT ON;
4546
SET STATISTICS XML OFF;
@@ -1637,6 +1638,29 @@ END;'
16371638
-- If test restore then blow the database away (be careful)
16381639
IF @TestRestore = 1
16391640
BEGIN
1641+
1642+
IF @VerifyRestoreWithStoredProcedure IS NOT NULL AND LEN(LTRIM(@VerifyRestoreWithStoredProcedure)) > 0
1643+
BEGIN
1644+
PRINT 'Attempting to run ' + @VerifyRestoreWithStoredProcedure
1645+
SET @sql = N'EXEC ' + @RestoreDatabaseName + '.' + @VerifyRestoreWithStoredProcedure
1646+
1647+
IF @Debug = 1 OR @Execute = 'N'
1648+
BEGIN
1649+
IF @sql IS NULL PRINT '@sql is NULL for Verify Restore with Stored Procedure'
1650+
PRINT @sql
1651+
END
1652+
1653+
IF @RunRecovery = 0
1654+
BEGIN
1655+
PRINT 'Unable to run Verify Restore with Stored Procedure as database is not recovered. Run command again with @RunRecovery = 1'
1656+
END
1657+
ELSE
1658+
BEGIN
1659+
IF @Debug IN (0, 1) AND @Execute = 'Y'
1660+
EXEC sp_executesql @sql
1661+
END
1662+
END
1663+
16401664
SET @sql = N'DROP DATABASE ' + @RestoreDatabaseName + NCHAR(13);
16411665

16421666
IF @Debug = 1 OR @Execute = 'N'

0 commit comments

Comments
 (0)