-- Stored Procedure: dbo.DbLogSizeTrend -- Bill Wunder use admin GO SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS ON GO if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[DbLogSizeTrend]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) drop procedure [dbo].[DbLogSizeTrend] GO CREATE PROCEDURE [dbo].[DbLogSizeTrend] @DbName sysname = null AS /******************************************************************************************************* * admin.dbo.dbLogSizeTrend * Creator: Bill Wunder * Date: 3-11-2002 * Outline: show log space over time * usage: * EXECUTE admin.dbo.dbLogSizeTrend * Notes: * * Modifications * developer name date brief description * ------------------ -------- ------------------------------------------------------------ * ********************************************************************************************************/ -- declare variables -- create temp tables -- set session SET NOCOUNT ON -- body of stored procedure if @DbName is null -- all select DbName, cast(max(SampleDate) as varchar(11)) as [Latest Date at this size], LogFileSize_KB, LogFileSizeUsed_KB, datepart(dw, SampleDate) as [weekday] from admin.dbo.DbPerfHistory group by DbName, LogFileSize_KB, LogFileSizeUsed_KB, datepart(dw, SampleDate) order by DbName, max(SampleDate) else -- only one db select Dbname, cast(max(SampleDate) as varchar(11)) as [Latest date at this size], LogFileSize_KB, LogFileSizeUsed_KB, datepart(dw, SampleDate) as [weekday] from admin.dbo.DbPerfHistory where DbName = @DbName group by DbName, LogFileSize_KB , LogFileSizeUsed_KB, datepart(dw, SampleDate) order by max(SampleDate) RETURN GO SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS ON GO