Introduction
Below script will give the command to execute to change the database auto-growth. If you need to execute for only a single database, then please copy the relevant rows and execute.
SQL Script for database Auto Growth
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
--================================ -- -- Owner: SOYELUDDIN BISWAS -- Created Date: 24/09/2019 -- -- Email: st.biswas99@gmail.com -- ================================== -- USE [tempdb/] GO IF OBJECT_ID('tempdb..#DBGrowth') IS NOT NULL DROP TABLE #DBGrowth Declare @GrowthType NVARCHAR(10) Declare @DatabaseName NVARCHAR(300) Declare @logicalName NVARCHAR(20) Declare @GrowthCMD NVARCHAR(300) --######### Growth Type and Value ############ --Example, If you want set growth in % then please mention your value in % such as @GrowthType='10%' --If want set growth in MB then please mention your value in KB such as @GrowthType='1024KB' -- Copy the below Growth Set @GrowthType='1024KB' Create Table #DBGrowth ( DatabaseName NVARCHAR(300), logicalName NVARCHAR(20), GrowthCMD NVARCHAR(300) ) INSERT INTO #DBGrowth select DBS.name, DBF.name, ' ALTER DATABASE ['+DBS.name+'] MODIFY FILE ( NAME = N'''+DBF.name+''', MAXSIZE = UNLIMITED, FILEGROWTH = '+@GrowthType+' )' from sys.databases DBS Inner Join sys.sysaltfiles DBF ON DBS.database_id=dbf.dbid WHERE DBS.name NOT IN ('master','tempdb','model','msdb') SELECT DatabaseName as [Database Name], logicalName as [Logical Name], GrowthCMD as [Command to execute] FROM #DBGrowth |
Using GUI
The same result can be obtain by using GUI SSMS also. Set Auto growth for SQL database using GUI