Closed csnhawkins closed 1 month ago
Simply put the below at the end of the script you have, then it become idempotent:
-- Drop Schema Database If Exists DECLARE @DROP nvarchar(100); DECLARE @RESULT NVARCHAR(200); SET @DROP = 'DROP DATABASE IF EXISTS' SET @RESULT = (@DROP+ ' '+@BackupDB) EXEC sp_executesql @RESULT
Works well! One issue is potentially that its fine writing multiple backups into the same file?
May need peer review, but happy this works
Simply put the below at the end of the script you have, then it become idempotent:
-- Drop Schema Database If Exists DECLARE @DROP nvarchar(100); DECLARE @RESULT NVARCHAR(200); SET @DROP = 'DROP DATABASE IF EXISTS' SET @RESULT = (@DROP+ ' '+@BackupDB) EXEC sp_executesql @RESULT