matrix0511
asked on
How can I Check to see if all logs and databases are set to Auto Grow in SQL 2008 Server?
We use SQL 2008 server running on OS: Windows 2008 R2.
I'm not very familiar with SQL 2008. I've only used older versions.
How can I Check to see if all logs and databases are set to Auto Grow in SQL 2008 Server?
Please provide steps.
Thanks!
I'm not very familiar with SQL 2008. I've only used older versions.
How can I Check to see if all logs and databases are set to Auto Grow in SQL 2008 Server?
Please provide steps.
Thanks!
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
check
SQL Server Database Growth and Autogrowth Settings
http://www.simple-talk.com/sql/database-administration/sql-server-database-growth-and-autogrowth-settings/
and the same idea as above post:
SELECT
name AS FileName,
size*1.0/128 AS FileSizeinMB,
'MaximumSizeinMB' =
CASE max_size
WHEN 0 THEN 'No growth is allowed.'
WHEN -1 THEN 'Autogrowth is on.'
WHEN 268435456
THEN 'Log file will grow to a maximum size of 2 TB.'
ELSE CAST (max_size*1.0/128 AS nvarchar(30))
END,
growth AS 'GrowthValue',
'GrowthIncrement' =
CASE
WHEN growth = 0 THEN 'File size is fixed and will not grow.'
WHEN growth > 0 AND is_percent_growth = 0
THEN 'Growth value is in units of 8-KB pages.'
ELSE 'Growth value is a percentage.'
END
FROM sys.database_files
SQL Server Database Growth and Autogrowth Settings
http://www.simple-talk.com/sql/database-administration/sql-server-database-growth-and-autogrowth-settings/
and the same idea as above post:
SELECT
name AS FileName,
size*1.0/128 AS FileSizeinMB,
'MaximumSizeinMB' =
CASE max_size
WHEN 0 THEN 'No growth is allowed.'
WHEN -1 THEN 'Autogrowth is on.'
WHEN 268435456
THEN 'Log file will grow to a maximum size of 2 TB.'
ELSE CAST (max_size*1.0/128 AS nvarchar(30))
END,
growth AS 'GrowthValue',
'GrowthIncrement' =
CASE
WHEN growth = 0 THEN 'File size is fixed and will not grow.'
WHEN growth > 0 AND is_percent_growth = 0
THEN 'Growth value is in units of 8-KB pages.'
ELSE 'Growth value is a percentage.'
END
FROM sys.database_files
Here is another solution through sys.master_files
SELECT
CAST(cast(g.name as varbinary(256)) AS sysname) AS [FileGroup_Name],
s.name AS [Name],
CAST(CASE s.file_id WHEN 1 THEN 1 ELSE 0 END AS bit) AS [IsPrimaryFile],
CAST(CASE when s.growth=0 THEN (CASE WHEN s.type = 2 THEN 0 ELSE 99 END) ELSE s.is_percent_growth END AS int) AS [GrowthType],
s.physical_name AS [FileName],
s.size * CONVERT(float,8) AS [Size],
CASE when s.max_size=-1 then -1 else s.max_size * CONVERT(float,8) END AS [MaxSize],
s.file_id AS [ID],
'Server[@Name=' + quotename(CAST(
serverproperty(N'Servernam e')
AS sysname),'''') + ']' + '/Database[@Name=' + quotename(db_name(),'''') + ']' + '/FileGroup[@Name=' + quotename(CAST(cast(g.name as varbinary(256)) AS sysname),'''') + ']' + '/File[@Name=' + quotename(s.name,'''') + ']' AS [Urn],
CAST(CASE s.is_percent_growth WHEN 1 THEN s.growth ELSE s.growth*8 END AS float) AS [Growth],
s.is_media_read_only AS [IsReadOnlyMedia],
s.is_read_only AS [IsReadOnly],
CAST(case s.state when 6 then 1 else 0 end AS bit) AS [IsOffline],
s.is_sparse AS [IsSparse]
FROM
sys.filegroups AS g
INNER JOIN sys.master_files AS s ON ((s.type = 2 or s.type = 0) --and s.database_id = db_id()
and (s.drop_lsn IS NULL)) AND (s.data_space_id=g.data_sp ace_id)
ORDER BY
[FileGroup_Name] ASC,[Name] ASC
SELECT
CAST(cast(g.name as varbinary(256)) AS sysname) AS [FileGroup_Name],
s.name AS [Name],
CAST(CASE s.file_id WHEN 1 THEN 1 ELSE 0 END AS bit) AS [IsPrimaryFile],
CAST(CASE when s.growth=0 THEN (CASE WHEN s.type = 2 THEN 0 ELSE 99 END) ELSE s.is_percent_growth END AS int) AS [GrowthType],
s.physical_name AS [FileName],
s.size * CONVERT(float,8) AS [Size],
CASE when s.max_size=-1 then -1 else s.max_size * CONVERT(float,8) END AS [MaxSize],
s.file_id AS [ID],
'Server[@Name=' + quotename(CAST(
serverproperty(N'Servernam
AS sysname),'''') + ']' + '/Database[@Name=' + quotename(db_name(),'''') + ']' + '/FileGroup[@Name=' + quotename(CAST(cast(g.name
CAST(CASE s.is_percent_growth WHEN 1 THEN s.growth ELSE s.growth*8 END AS float) AS [Growth],
s.is_media_read_only AS [IsReadOnlyMedia],
s.is_read_only AS [IsReadOnly],
CAST(case s.state when 6 then 1 else 0 end AS bit) AS [IsOffline],
s.is_sparse AS [IsSparse]
FROM
sys.filegroups AS g
INNER JOIN sys.master_files AS s ON ((s.type = 2 or s.type = 0) --and s.database_id = db_id()
and (s.drop_lsn IS NULL)) AND (s.data_space_id=g.data_sp
ORDER BY
[FileGroup_Name] ASC,[Name] ASC
ASKER
Thanks guys. Quick question. Where can i go int the SSMM to check if logs and DBs are set to AUTO GROW?
Thanks
Thanks
This article can guide you to locate auto growth in SSMS.
http://www.mytechmantra.com/LearnSQLServer/How-to-Change-SQL-Server-Database-Auto-Growth-Settings.html
http://www.mytechmantra.com/LearnSQLServer/How-to-Change-SQL-Server-Database-Auto-Growth-Settings.html
Query below will identity all files that do NOT have autogrow set:
SELECT DB_NAME(database_id) AS Db_Name, *
FROM sys.master_files
WHERE
growth = 0
SELECT DB_NAME(database_id) AS Db_Name, *
FROM sys.master_files
WHERE
growth = 0
Open in new window
Refer: http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/105c00c4-eae8-4875-b63c-8b953ee43e23/