Skip to content

Instantly share code, notes, and snippets.

@ghotz
Created May 8, 2024 10:01
Show Gist options
  • Save ghotz/9e1d970357a8c204cc798b1b21e04fbe to your computer and use it in GitHub Desktop.
Save ghotz/9e1d970357a8c204cc798b1b21e04fbe to your computer and use it in GitHub Desktop.
Evaluate and standardize database recovery time
SELECT
[name] AS database_name, target_recovery_time_in_seconds
, CASE
WHEN target_recovery_time_in_seconds = 60
THEN NULL
ELSE 'ALTER DATABASE [' + [name] + ']'
+ ' SET TARGET_RECOVERY_TIME = 60 SECONDS;'
END AS alter_command
FROM sys.databases
WHERE [name] NOT IN ('master','model','msdb','tempdb')
AND state_desc = 'ONLINE'
ORDER BY [name]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment