Hi,
I've written a small procedure to show how often a database is growing over the course of a day.
This works fine on some databases in the instance but returns nothing for others, I'm assuming that as the procedure uses the default trace file there has not been any FILEGROWTH changes for that database over the period logged in the .TRC file.
If that's true then is it possible to force a database to grow by a small amount so that I can see the DDL it's being logged? Also, can this forcing the database to grow be done online?
This is the code snippet:
SELECT @path = REVERSE(SUBSTRING(REVERSE([path]), CHARINDEX('\', REVERSE([path])), 260)) + N'log.trc' FROM sys.traces WHERE is_default = 1; SELECT DatabaseName, CAST(StartTime AS DATE) AS [Date], COUNT(1) AS [ExtentsPerDay], FileType = CASE EventClass WHEN 92 THEN 'Data' WHEN 93 THEN 'Log' END FROM sys.fn_trace_gettable(@path, DEFAULT) WHERE EventClass IN (92,93) AND DatabaseName = @Database AND ( @Type IS NULL OR (UPPER(@Type) = 'DATA' AND EventClass = 92) OR @Type IS NULL OR (UPPER(@Type) = 'LOG' AND EventClass = 93) )