Database File Growth
USE: To find out recent database files growth.
IF(SELECT CONVERT(int,value_in_use) FROM sys.configurations WHERE [name] = 'default trace enabled' ) = 1 BEGIN declare @curr_tracefilename varchar(500) ; declare @base_tracefilename varchar(500) ; declare @indx int ; SELECT @curr_tracefilename = [path] FROM sys.traces where is_default = 1 ; SET @curr_tracefilename = REVERSE(@curr_tracefilename); SELECT @indx = PATINDEX('%%', @curr_tracefilename) ; SET @curr_tracefilename = REVERSE(@curr_tracefilename) ; SET @base_tracefilename = LEFT( @curr_tracefilename,LEN(@curr_tracefilename) - @indx) + 'log.trc' ; SELECT (DENSE_RANK() OVER(ORDER BY StartTime DESC))%2 AS [l1], CONVERT(int, EventClass) [EventClass], DatabaseName, [Filename], (Duration/1000) [Duration], StartTime, EndTime, (IntegerData*8.0/1024) [ChangeInSize] FROM ::fn_trace_gettable( @base_tracefilename, default ) WHERE EventClass >= 92 AND EventClass <= 95 AND ServerName = @@SERVERNAME AND DatabaseName = DB_NAME() ORDER BY StartTime DESC; END GO