HuxleyKendell / AutoRodent

2 stars 0 forks source link

CreateSchemaBackup Script - Add additional logic to drop the _Schema database after it gets backed up #1

Closed csnhawkins closed 1 month ago

csnhawkins commented 2 months 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

HuxleyKendell commented 1 month ago

Works well! One issue is potentially that its fine writing multiple backups into the same file?

HuxleyKendell commented 1 month ago

May need peer review, but happy this works