Skip to content

Commit 213f104

Browse files
authored
Merge pull request #3443 from gdoddsy/issue_3429
Update sp_DatabaseRestore.sql
2 parents aa84eb9 + 9be50b1 commit 213f104

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

sp_DatabaseRestore.sql

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,32 +1635,31 @@ END;'
16351635
EXECUTE [dbo].[CommandExecute] @DatabaseContext = 'master', @Command = @sql, @CommandType = 'UPDATE', @Mode = 1, @DatabaseName = @UnquotedRestoreDatabaseName, @LogToTable = 'Y', @Execute = 'Y';
16361636
END;
16371637

1638-
-- If test restore then blow the database away (be careful)
1639-
IF @TestRestore = 1
1640-
BEGIN
1641-
1642-
IF @RunStoredProcAfterRestore IS NOT NULL AND LEN(LTRIM(@RunStoredProcAfterRestore)) > 0
1643-
BEGIN
1644-
PRINT 'Attempting to run ' + @RunStoredProcAfterRestore
1645-
SET @sql = N'EXEC ' + @RestoreDatabaseName + '.' + @RunStoredProcAfterRestore
1638+
IF @RunStoredProcAfterRestore IS NOT NULL AND LEN(LTRIM(@RunStoredProcAfterRestore)) > 0
1639+
BEGIN
1640+
PRINT 'Attempting to run ' + @RunStoredProcAfterRestore
1641+
SET @sql = N'EXEC ' + @RestoreDatabaseName + '.' + @RunStoredProcAfterRestore
16461642

1647-
IF @Debug = 1 OR @Execute = 'N'
1648-
BEGIN
1649-
IF @sql IS NULL PRINT '@sql is NULL when building for @RunStoredProcAfterRestore'
1650-
PRINT @sql
1651-
END
1643+
IF @Debug = 1 OR @Execute = 'N'
1644+
BEGIN
1645+
IF @sql IS NULL PRINT '@sql is NULL when building for @RunStoredProcAfterRestore'
1646+
PRINT @sql
1647+
END
16521648

1653-
IF @RunRecovery = 0
1654-
BEGIN
1655-
PRINT 'Unable to run Run Stored Procedure After Restore 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
1649+
IF @RunRecovery = 0
1650+
BEGIN
1651+
PRINT 'Unable to run Run Stored Procedure After Restore as database is not recovered. Run command again with @RunRecovery = 1'
1652+
END
1653+
ELSE
1654+
BEGIN
1655+
IF @Debug IN (0, 1) AND @Execute = 'Y'
1656+
EXEC sp_executesql @sql
1657+
END
1658+
END
16631659

1660+
-- If test restore then blow the database away (be careful)
1661+
IF @TestRestore = 1
1662+
BEGIN
16641663
SET @sql = N'DROP DATABASE ' + @RestoreDatabaseName + NCHAR(13);
16651664

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

0 commit comments

Comments
 (0)