Skip to content

Instantly share code, notes, and snippets.

@ghotz
Last active March 6, 2026 10:14
Show Gist options
  • Select an option

  • Save ghotz/783ed7c20104ccc22158fc670d3244dd to your computer and use it in GitHub Desktop.

Select an option

Save ghotz/783ed7c20104ccc22158fc670d3244dd to your computer and use it in GitHub Desktop.
Evaluate Auto Shrink database option
SELECT
[name] AS database_name, is_auto_shrink_on
, 'ALTER DATABASE [' + [name] + ']' + ' SET AUTO_SHRINK OFF;' AS alter_command
FROM sys.databases
WHERE [name] NOT IN ('master','model','msdb','tempdb')
AND state_desc = 'ONLINE'
AND is_auto_shrink_on = 1
ORDER BY [name]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment