<?xml version="1.0" encoding="utf-8"?>
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
  <Body>
    <ReportItems>
      <Textbox Name="Textbox1">
        <CanGrow>true</CanGrow>
        <KeepTogether>true</KeepTogether>
        <Paragraphs>
          <Paragraph>
            <TextRuns>
              <TextRun>
                <Value>Monitor Create Procedures Code</Value>
                <Style>
                  <FontSize>22pt</FontSize>
                </Style>
              </TextRun>
            </TextRuns>
            <Style>
              <TextAlign>Center</TextAlign>
            </Style>
          </Paragraph>
        </Paragraphs>
        <rd:DefaultName>Textbox1</rd:DefaultName>
        <Top>0.23833in</Top>
        <Left>0.34667in</Left>
        <Height>0.66667in</Height>
        <Width>7.4in</Width>
        <Style>
          <Border>
            <Style>None</Style>
          </Border>
          <BackgroundColor>LightSteelBlue</BackgroundColor>
          <VerticalAlign>Middle</VerticalAlign>
          <PaddingLeft>2pt</PaddingLeft>
          <PaddingRight>2pt</PaddingRight>
          <PaddingTop>2pt</PaddingTop>
          <PaddingBottom>2pt</PaddingBottom>
        </Style>
      </Textbox>
      <Textbox Name="Textbox2">
        <CanGrow>true</CanGrow>
        <KeepTogether>true</KeepTogether>
        <Paragraphs>
          <Paragraph>
            <TextRuns>
              <TextRun>
                <Value>USE [AdminMonitor]
GO
/****** Object:  StoredProcedure [dbo].[GetBlockingCount]    Script Date: 5/11/2023 7:55:56 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetBlockingCount]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[GetBlockingCount] AS' 
END
GO
ALTER Procedure [dbo].[GetBlockingCount]
		@NumDays INT

AS

--EXEC GetBlockingCount 45

DECLARE @Days INT

SELECT @Days = [ConfigValue]
FROM AdminMonitor.[dbo].[Config]
WHERE ConfigTitle = 'DataRetention'

SELECT @numdays  = CASE @numdays WHEN 24 THEN 24 
			WHEN 7 THEN 168
			WHEN 14 THEN 336
			WHEN 30 THEN 720
			ELSE @days * 24
 END


SET @numDays = @numDays * -1

SELECT  [DateOfCheck]
      ,[NumberOfEvents]
  FROM [AdminMonitor].[dbo].[BlockingCount]
  WHERE DateOfCheck  &gt; DATEADD(Hour, @numDays, GETDATE())
  Order by DateofCheck
GO
/****** Object:  StoredProcedure [dbo].[GetBlockingDetail]    Script Date: 5/11/2023 7:55:56 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetBlockingDetail]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[GetBlockingDetail] AS' 
END
GO
ALTER Procedure [dbo].[GetBlockingDetail]
		@NumDays INT

AS

--EXEC GetBlockingDetail 45

DECLARE @Days INT

SELECT @Days = [ConfigValue]
FROM [dbo].[Config]
WHERE ConfigTitle = 'DataRetention'

SELECT @numdays  = CASE @numdays WHEN 24 THEN 24 
			WHEN 7 THEN 168
			WHEN 14 THEN 336
			WHEN 30 THEN 720
			ELSE @days * 24
 END


SET @numDays = @numDays * -1

SELECT [LocalTimeOfBlocking]
,[UTCTimeOfBlocking]
,[DatabaseName] 
FROM [dbo].[BlockingDetail]
  WHERE [LocalTimeOfBlocking]  &gt; DATEADD(Hour, @numDays, GETDATE())
  Order by [LocalTimeOfBlocking]
GO
/****** Object:  StoredProcedure [dbo].[GetDeadLockCount]    Script Date: 5/11/2023 7:55:56 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetDeadLockCount]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[GetDeadLockCount] AS' 
END
GO
ALTER Procedure [dbo].[GetDeadLockCount]
		@NumDays INT

AS

--EXEC GetDeadLockCount 45

DECLARE @Days INT

SELECT @Days = [ConfigValue]
FROM AdminMonitor.[dbo].[Config]
WHERE ConfigTitle = 'DataRetention'

SELECT @numdays  = CASE @numdays WHEN 24 THEN 24 
			WHEN 7 THEN 168
			WHEN 14 THEN 336
			WHEN 30 THEN 720
			ELSE @days * 24
 END


SET @numDays = @numDays * -1

SELECT  [DateOfCheck]
      ,[NumberOfEvents]
  FROM [AdminMonitor].[dbo].[DeadlockCount]
  WHERE DateOfCheck  &gt; DATEADD(Hour, @numDays, GETDATE())
  Order by DateofCheck
GO
/****** Object:  StoredProcedure [dbo].[GetDeadLockDetail]    Script Date: 5/11/2023 7:55:56 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetDeadLockDetail]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[GetDeadLockDetail] AS' 
END
GO

ALTER Procedure [dbo].[GetDeadLockDetail]
		@NumDays INT

AS

--EXEC GetDeadLockDetail 45

DECLARE @Days INT

SELECT @Days = [ConfigValue]
FROM [dbo].[Config]
WHERE ConfigTitle = 'DataRetention'

SELECT @numdays  = CASE @numdays WHEN 24 THEN 24 
			WHEN 7 THEN 168
			WHEN 14 THEN 336
			WHEN 30 THEN 720
			ELSE @days * 24
 END


SET @numDays = @numDays * -1

SELECT [LocalTimeOfDeadLock]
,[UTCTimeOfDeadlock]
,[DatabaseName] 
FROM [dbo].[DeadlockDetail]
  WHERE [LocalTimeOfDeadLock]  &gt; DATEADD(Hour, @numDays, GETDATE())
  Order by [LocalTimeOfDeadLock]
GO
/****** Object:  StoredProcedure [dbo].[GetPerfData]    Script Date: 5/11/2023 7:55:56 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetPerfData]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[GetPerfData] AS' 
END
GO

ALTER Procedure  [dbo].[GetPerfData]
	  @ObjectName Varchar(100)
	, @InstanceName varchar(100)
	, @CounterName varchar(100)
	, @NumMinutes INT

AS



DECLARE @Days INT

SELECT @Days = [ConfigValue]
FROM [dbo].[Config]
WHERE ConfigTitle = 'DataRetention'

SELECT @numminutes  = CASE @numminutes WHEN 15 THEN 15 
			WHEN 60 THEN 60
			WHEN 24 THEN 1440
			WHEN 14 THEN 20160
			WHEN 30 THEN 43200
			ELSE @days * 24 * 60
 END


SET @numminutes = @numminutes * -1

SELECT t.CounterName
	, t.instanceName
	, t.objectname
		, c.DateTimeOfCapture
		, c.counterValue
		, Case When c.countertype = 272696576 
 then c.counterValue -LAG(c.countervalue, 1,c.counterValue) OVER (ORDER BY c.DateTimeOfCapture) ELSE c.counterValue END AS 'DifferenceFromPreviousTime'
	, c.countertype
		FROM AdminMonitor.[dbo].[PerfCountersCaptured] C
	INNER JOIN AdminMonitor.[dbo].[PerformanceCountersToCapture] T
		ON c.counterid = T.CounterID
WHERE t.CounterName = @CounterName
			AND t.instanceName = @InstanceName
				AND t.objectName = @ObjectName
	AND c.DateTimeOfCapture &gt; DATEADD(minute, @numminutes, GETDATE())
GO
/****** Object:  StoredProcedure [dbo].[GetReadWriteLatency]    Script Date: 5/11/2023 7:55:56 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetReadWriteLatency]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[GetReadWriteLatency] AS' 
END
GO
ALTER Procedure  [dbo].[GetReadWriteLatency]
	  @DatabaseName Varchar(100)
	  , @NumMinutes INT
AS



DECLARE @Days INT

SELECT @Days = [ConfigValue]
FROM [dbo].[Config]
WHERE ConfigTitle = 'DataRetention'

SELECT @numminutes  = CASE @numminutes WHEN 15 THEN 15 
			WHEN 60 THEN 60
			WHEN 24 THEN 1440
			WHEN 14 THEN 20160
			WHEN 30 THEN 43200
			ELSE @days * 24 * 60
 END


SET @numminutes = @numminutes * -1

SELECT [DatabaseName]
	, [FileType]
	, [DriveLetter]
	, [ReadLatency]
	, [WriteLatency]
	, [PhysicalFile]
	, [DateOfCapture]
FROM [dbo].[ReadWriteLatency]
WHERE [DatabaseName] = @DatabaseName
	AND [DateOfCapture] &gt; DATEADD(minute, @numminutes, GETDATE())
GO
/****** Object:  StoredProcedure [dbo].[GetWaitTypeData]    Script Date: 5/11/2023 7:55:56 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetWaitTypeData]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[GetWaitTypeData] AS' 
END
GO

ALTER Procedure [dbo].[GetWaitTypeData]
	@TypeName Varchar(100)
	, @NumMinutes INT
AS


DECLARE @Days INT

SELECT @Days = [ConfigValue]
FROM [dbo].[Config]
WHERE ConfigTitle = 'DataRetention'

SELECT @numminutes  = CASE @numminutes WHEN 15 THEN 15 
			WHEN 60 THEN 60
			WHEN 24 THEN 1440
			WHEN 14 THEN 20160
			WHEN 30 THEN 43200
			ELSE @days * 24 * 60
 END


SET @numminutes = @numminutes * -1

SELECT T.WaitTypeName
		,c.TotalWaitTimeSec AS 'BaseTotalWaitTimeSec'
		, C.ResourceWaitTimeSec AS 'BaseResourceWaitTimeSec'
		, C. SignalWaitTimeSec AS 'BaseSignalWaitTimeSec'
		, c. WaitCount AS 'BaseWaitCount'
		, c.DateTimeOfCapture
		, c.TotalWaitTimeSec -LAG(c.TotalWaitTimeSec, 1,c.TotalWaitTimeSec) OVER (ORDER BY c.DateTimeOfCapture) AS 'TotalWaitTimeSec'
		, C.ResourceWaitTimeSec -LAG(C.ResourceWaitTimeSec, 1,C.ResourceWaitTimeSec) OVER (ORDER BY c.DateTimeOfCapture) AS 'ResourceWaitTimeSec'
		, C. SignalWaitTimeSec -LAG(C.SignalWaitTimeSec, 1,C.SignalWaitTimeSec) OVER (ORDER BY c.DateTimeOfCapture) AS 'SignalWaitTimeSec'
		, c. WaitCount -LAG(c. WaitCount, 1,c. WaitCount) OVER (ORDER BY c.DateTimeOfCapture) AS 'WaitCount'
		FROM [dbo].[WaitCaptured] C
	INNER JOIN [dbo].[WaitTypesToCollect] T
		ON C.WaitTypeID = T.WaitTypeID
WHERE t.WaitTypeName = @TypeName 
	AND c.DateTimeOfCapture &gt; DATEADD(minute, @numminutes, GETDATE())
GO
/****** Object:  StoredProcedure [dbo].[GetWindowsCountersAvailableMem]    Script Date: 5/11/2023 7:55:56 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetWindowsCountersAvailableMem]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[GetWindowsCountersAvailableMem] AS' 
END
GO
ALTER Procedure [dbo].[GetWindowsCountersAvailableMem]
		@NumMinutes INT

AS

--EXEC GetWindowsCountersAvailableMem 45

DECLARE @Days INT

SELECT @Days = [ConfigValue]
FROM [dbo].[Config]
WHERE ConfigTitle = 'DataRetention'

SELECT @numminutes  = CASE @numminutes WHEN 15 THEN 15 
			WHEN 60 THEN 60
			WHEN 90 THEN 90
			WHEN 24 THEN 1440
			WHEN 14 THEN 20160
			WHEN 30 THEN 43200
			ELSE @days * 24 * 60
 END


SET @numMinutes = @numMinutes * -1

SELECT [WindowsCounterName]
		, [CounterValue]
		, [DateTimeOfCapture]
FROM [dbo].[WindowsCountersCaptured]
WHERE [WindowsCounterName] LIKE
	'\\%\memory\available mbytes'
AND [DateTimeOfCapture] &gt; DATEADD(minute, @numMinutes, GETDATE())
GO
/****** Object:  StoredProcedure [dbo].[GetWindowsCountersAvgDiskRead]    Script Date: 5/11/2023 7:55:56 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetWindowsCountersAvgDiskRead]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[GetWindowsCountersAvgDiskRead] AS' 
END
GO
ALTER Procedure [dbo].[GetWindowsCountersAvgDiskRead]
		@NumMinutes INT

AS

--EXEC GetWindowsCountersAvgDiskRead 45

DECLARE @Days INT

SELECT @Days = [ConfigValue]
FROM [dbo].[Config]
WHERE ConfigTitle = 'DataRetention'

SELECT @numminutes  = CASE @numminutes WHEN 15 THEN 15 
			WHEN 60 THEN 60
			WHEN 90 THEN 90
			WHEN 24 THEN 1440
			WHEN 14 THEN 20160
			WHEN 30 THEN 43200
			ELSE @days * 24 * 60
 END


SET @numMinutes = @numMinutes * -1

SELECT [WindowsCounterName]
		, [CounterValue]
		, [DateTimeOfCapture]
FROM [dbo].[WindowsCountersCaptured]
WHERE [WindowsCounterName] LIKE
	'\\%\physicaldisk(_total)\avg. disk sec/read'
AND [DateTimeOfCapture] &gt; DATEADD(minute, @numMinutes, GETDATE())
GO
/****** Object:  StoredProcedure [dbo].[GetWindowsCountersAvgDiskWrite]    Script Date: 5/11/2023 7:55:56 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetWindowsCountersAvgDiskWrite]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[GetWindowsCountersAvgDiskWrite] AS' 
END
GO
ALTER Procedure [dbo].[GetWindowsCountersAvgDiskWrite]
		@NumMinutes INT

AS

--EXEC GetWindowsCountersAvgDiskWrite 45

DECLARE @Days INT

SELECT @Days = [ConfigValue]
FROM [dbo].[Config]
WHERE ConfigTitle = 'DataRetention'

SELECT @numminutes  = CASE @numminutes WHEN 15 THEN 15 
			WHEN 60 THEN 60
			WHEN 90 THEN 90
			WHEN 24 THEN 1440
			WHEN 14 THEN 20160
			WHEN 30 THEN 43200
			ELSE @days * 24 * 60
 END


SET @numMinutes = @numMinutes * -1

SELECT [WindowsCounterName]
		, [CounterValue]
		, [DateTimeOfCapture]
FROM [dbo].[WindowsCountersCaptured]
WHERE [WindowsCounterName] LIKE
	'\\%\physicaldisk(_total)\avg. disk sec/write'
AND [DateTimeOfCapture] &gt; DATEADD(minute, @numMinutes, GETDATE())
GO
/****** Object:  StoredProcedure [dbo].[GetWindowsCountersCacheHitRatio]    Script Date: 5/11/2023 7:55:56 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetWindowsCountersCacheHitRatio]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[GetWindowsCountersCacheHitRatio] AS' 
END
GO
ALTER Procedure [dbo].[GetWindowsCountersCacheHitRatio]
		@NumMinutes INT

AS

--EXEC GetWindowsCountersCacheHitRatio 45

DECLARE @Days INT

SELECT @Days = [ConfigValue]
FROM [dbo].[Config]
WHERE ConfigTitle = 'DataRetention'

SELECT @numminutes  = CASE @numminutes WHEN 15 THEN 15 
			WHEN 60 THEN 60
			WHEN 90 THEN 90
			WHEN 24 THEN 1440
			WHEN 14 THEN 20160
			WHEN 30 THEN 43200
			ELSE @days * 24 * 60
 END


SET @numMinutes = @numMinutes * -1

SELECT [WindowsCounterName]
		, [CounterValue]
		, [DateTimeOfCapture]
FROM [dbo].[WindowsCountersCaptured]
WHERE [WindowsCounterName] LIKE
	'\\%\sqlserver:buffer manager\buffer cache hit ratio'
AND [DateTimeOfCapture] &gt; DATEADD(minute, @numMinutes, GETDATE())
GO
/****** Object:  StoredProcedure [dbo].[GetWindowsCountersPageFileUsage]    Script Date: 5/11/2023 7:55:56 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetWindowsCountersPageFileUsage]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[GetWindowsCountersPageFileUsage] AS' 
END
GO
ALTER Procedure [dbo].[GetWindowsCountersPageFileUsage]
		@NumMinutes INT

AS

--EXEC GetWindowsCountersPageFileUsage 45

DECLARE @Days INT

SELECT @Days = [ConfigValue]
FROM [dbo].[Config]
WHERE ConfigTitle = 'DataRetention'

SELECT @numminutes  = CASE @numminutes WHEN 15 THEN 15 
			WHEN 60 THEN 60
			WHEN 90 THEN 90
			WHEN 24 THEN 1440
			WHEN 14 THEN 20160
			WHEN 30 THEN 43200
			ELSE @days * 24 * 60
 END


SET @numMinutes = @numMinutes * -1

SELECT [WindowsCounterName]
		, [CounterValue]
		, [DateTimeOfCapture]
FROM [dbo].[WindowsCountersCaptured]
WHERE [WindowsCounterName] LIKE
	'\\%\paging file(_total)\% usage'
AND [DateTimeOfCapture] &gt; DATEADD(minute, @numMinutes, GETDATE())
GO
/****** Object:  StoredProcedure [dbo].[GetWindowsCountersProcessorQueueLength]    Script Date: 5/11/2023 7:55:56 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetWindowsCountersProcessorQueueLength]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[GetWindowsCountersProcessorQueueLength] AS' 
END
GO
ALTER Procedure [dbo].[GetWindowsCountersProcessorQueueLength]
		@NumMinutes INT

AS

--EXEC GetWindowsCountersProcessorQueueLength 45

DECLARE @Days INT

SELECT @Days = [ConfigValue]
FROM [dbo].[Config]
WHERE ConfigTitle = 'DataRetention'

SELECT @numminutes  = CASE @numminutes WHEN 15 THEN 15 
			WHEN 60 THEN 60
			WHEN 90 THEN 90
			WHEN 24 THEN 1440
			WHEN 14 THEN 20160
			WHEN 30 THEN 43200
			ELSE @days * 24 * 60
 END


SET @numMinutes = @numMinutes * -1

SELECT [WindowsCounterName]
		, [CounterValue]
		, [DateTimeOfCapture]
FROM [dbo].[WindowsCountersCaptured]
WHERE [WindowsCounterName] LIKE
	'\\%\system\processor queue length'
AND [DateTimeOfCapture] &gt; DATEADD(minute, @numMinutes, GETDATE())
GO
/****** Object:  StoredProcedure [dbo].[GetWindowsCountersProcessorTime]    Script Date: 5/11/2023 7:55:56 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetWindowsCountersProcessorTime]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[GetWindowsCountersProcessorTime] AS' 
END
GO
ALTER Procedure [dbo].[GetWindowsCountersProcessorTime]
		@NumMinutes INT

AS

--EXEC GetWindowsCountersProcessorTime 45

DECLARE @Days INT

SELECT @Days = [ConfigValue]
FROM [dbo].[Config]
WHERE ConfigTitle = 'DataRetention'

SELECT @numminutes  = CASE @numminutes WHEN 15 THEN 15 
			WHEN 60 THEN 60
			WHEN 90 THEN 90
			WHEN 24 THEN 1440
			WHEN 14 THEN 20160
			WHEN 30 THEN 43200
			ELSE @days * 24 * 60
 END


SET @numMinutes = @numMinutes * -1

SELECT [WindowsCounterName]
		, [CounterValue]
		, [DateTimeOfCapture]
FROM [dbo].[WindowsCountersCaptured]
WHERE [WindowsCounterName] LIKE
	'\\%\processor(_total)\% processor time'
AND [DateTimeOfCapture] &gt; DATEADD(minute, @numMinutes, GETDATE())
GO</Value>
                <Style />
              </TextRun>
            </TextRuns>
            <Style />
          </Paragraph>
          <Paragraph>
            <TextRuns>
              <TextRun>
                <Value />
                <Style />
              </TextRun>
            </TextRuns>
            <Style />
          </Paragraph>
          <Paragraph>
            <TextRuns>
              <TextRun>
                <Value />
                <Style />
              </TextRun>
            </TextRuns>
            <Style />
          </Paragraph>
          <Paragraph>
            <TextRuns>
              <TextRun>
                <Value>USE AdminMonitor

EXECUTE sp_executesql   
          N'CREATE Procedure  [dbo].[GetServerActivity]
 @NumMinutes INT
AS

DECLARE @Days INT

SELECT @Days = [ConfigValue]
FROM AdminMonitor.[dbo].[Config]
WHERE ConfigTitle = ''DataRetention''

SELECT @numminutes  = CASE @numminutes WHEN 24 THEN 1440 
			WHEN 7 THEN 10080
			WHEN 14 THEN 20160
			WHEN 30 THEN 43200
			ELSE @days * 24 * 60
 END


SET @numminutes = @numminutes * -1

SELECT SUM([SpidCount]) AS ''NumSpids''
, Convert(date, DateTimeOfCapture) AS ''Date''
	, DatePart(Hour,datetimeofCapture) AS ''Hour''
FROM AdminMonitor.[dbo].[ServerActivity]
WHERE [DateTimeOfCapture] &gt; DATEADD(minute, @numminutes, GETDATE())
GROUP BY Convert(date, DateTimeOfCapture)
	, DatePart(hour,datetimeofCapture)
	'


Select * from sysdatabases</Value>
                <Style />
              </TextRun>
            </TextRuns>
            <Style />
          </Paragraph>
          <Paragraph>
            <TextRuns>
              <TextRun>
                <Value />
                <Style />
              </TextRun>
            </TextRuns>
            <Style />
          </Paragraph>
          <Paragraph>
            <TextRuns>
              <TextRun>
                <Value />
                <Style />
              </TextRun>
            </TextRuns>
            <Style />
          </Paragraph>
          <Paragraph>
            <TextRuns>
              <TextRun>
                <Value />
                <Style />
              </TextRun>
            </TextRuns>
            <Style />
          </Paragraph>
          <Paragraph>
            <TextRuns>
              <TextRun>
                <Value>CREATE Procedure  [dbo].[GetDatabaseGrowth]
	  @DatabaseName Varchar(100)
	  , @NumDays INT
AS



DECLARE @Days INT

SELECT @Days = [ConfigValue]
FROM [dbo].[Config]
WHERE ConfigTitle = 'DatabaseGrowthDataRetention'


SET @numdays = @numdays * -1

SELECT [DatabaseName]
		,[LogSizeMB]
		,[DataSizeMB]
		,[TotalSizeMB]
		,[DateOfCapture]
FROM AdminMonitor.dbo.DatabaseSize
WHERE [DatabaseName] = @DatabaseName
	AND [DateOfCapture] &gt; DATEADD(DAY, @numDays, GETDATE())</Value>
                <Style />
              </TextRun>
            </TextRuns>
            <Style />
          </Paragraph>
          <Paragraph>
            <TextRuns>
              <TextRun>
                <Value />
                <Style />
              </TextRun>
            </TextRuns>
            <Style />
          </Paragraph>
          <Paragraph>
            <TextRuns>
              <TextRun>
                <Value />
                <Style />
              </TextRun>
            </TextRuns>
            <Style />
          </Paragraph>
          <Paragraph>
            <TextRuns>
              <TextRun>
                <Value>CREATE Procedure [dbo].[GetQueryTimeOutsHourlyCount]
 @NumMinutes INT
AS


DECLARE @Days INT

SELECT @Days = [ConfigValue]
FROM [dbo].[Config]
WHERE ConfigTitle = 'DataRetention'

SELECT @numminutes  = CASE @numminutes WHEN 1 THEN 60 
			WHEN 2 THEN 120
			WHEN 24 THEN 1440
			WHEN 14 THEN 20160
			WHEN 30 THEN 43200
			ELSE @days * 24 * 60
 END


SET @numminutes = @numminutes * -1



SELECT
	  DBName AS 'DatabaseName'
	, DATEPART(HOUR, localtimeoftimeout) AS 'HourOfTimeout'
	, CONVERT(DATE, LocalTimeOfTimeout) AS 'DateOfTimeout'
	, CASE WHEN DBNAME = 'No Timeouts Found' THEN 0 ELSE COUNT(*) END AS 'NumberOfTimeoutsInTimeRage'
FROM AdminMonitor.[dbo].[QueryTimeOut]
WHERE localtimeoftimeout &gt; DATEADD(MINUTE, @numminutes, GETDATE())
GROUP BY DBName,
		 DATEPART(HOUR, localtimeoftimeout), 
		 CONVERT(DATE, LocalTimeOfTimeout)
ORDER BY CONVERT(DATE, LocalTimeOfTimeout)
	   , DATEPART(HOUR, localtimeoftimeout)
</Value>
                <Style />
              </TextRun>
            </TextRuns>
            <Style />
          </Paragraph>
          <Paragraph>
            <TextRuns>
              <TextRun>
                <Value />
                <Style />
              </TextRun>
            </TextRuns>
            <Style />
          </Paragraph>
          <Paragraph>
            <TextRuns>
              <TextRun>
                <Value />
                <Style />
              </TextRun>
            </TextRuns>
            <Style />
          </Paragraph>
          <Paragraph>
            <TextRuns>
              <TextRun>
                <Value />
                <Style />
              </TextRun>
            </TextRuns>
            <Style />
          </Paragraph>
        </Paragraphs>
        <rd:DefaultName>Textbox2</rd:DefaultName>
        <Top>1.97167in</Top>
        <Left>0.36333in</Left>
        <Height>117.68334in</Height>
        <Width>7.4in</Width>
        <ZIndex>1</ZIndex>
        <Style>
          <Border>
            <Style>None</Style>
          </Border>
          <BackgroundColor>LightGrey</BackgroundColor>
          <PaddingLeft>2pt</PaddingLeft>
          <PaddingRight>2pt</PaddingRight>
          <PaddingTop>2pt</PaddingTop>
          <PaddingBottom>2pt</PaddingBottom>
        </Style>
      </Textbox>
      <Textbox Name="Textbox3">
        <CanGrow>true</CanGrow>
        <KeepTogether>true</KeepTogether>
        <Paragraphs>
          <Paragraph>
            <TextRuns>
              <TextRun>
                <Value>This code creates the required stored procedures.  Export this report to Word to copy and paste.</Value>
                <Style>
                  <FontSize>14pt</FontSize>
                </Style>
              </TextRun>
            </TextRuns>
            <Style>
              <TextAlign>Center</TextAlign>
            </Style>
          </Paragraph>
        </Paragraphs>
        <rd:DefaultName>Textbox3</rd:DefaultName>
        <Top>1.04667in</Top>
        <Left>0.36333in</Left>
        <Height>0.76667in</Height>
        <Width>3.30833in</Width>
        <ZIndex>2</ZIndex>
        <Style>
          <Border>
            <Style>None</Style>
          </Border>
          <BackgroundColor>LightGrey</BackgroundColor>
          <VerticalAlign>Middle</VerticalAlign>
          <PaddingLeft>2pt</PaddingLeft>
          <PaddingRight>2pt</PaddingRight>
          <PaddingTop>2pt</PaddingTop>
          <PaddingBottom>2pt</PaddingBottom>
        </Style>
      </Textbox>
      <Textbox Name="Textbox4">
        <CanGrow>true</CanGrow>
        <KeepTogether>true</KeepTogether>
        <Paragraphs>
          <Paragraph>
            <TextRuns>
              <TextRun>
                <Value>Back to Previous Page</Value>
                <Style>
                  <FontSize>14pt</FontSize>
                </Style>
              </TextRun>
            </TextRuns>
            <Style>
              <TextAlign>Center</TextAlign>
            </Style>
          </Paragraph>
        </Paragraphs>
        <rd:DefaultName>Textbox4</rd:DefaultName>
        <ActionInfo>
          <Actions>
            <Action>
              <Drillthrough>
                <ReportName>MonitorViewMonitorCode</ReportName>
              </Drillthrough>
            </Action>
          </Actions>
        </ActionInfo>
        <Top>1.03in</Top>
        <Left>3.91333in</Left>
        <Height>0.78333in</Height>
        <Width>3.83333in</Width>
        <ZIndex>3</ZIndex>
        <Style>
          <Border>
            <Style>None</Style>
          </Border>
          <BackgroundColor>LightSteelBlue</BackgroundColor>
          <VerticalAlign>Middle</VerticalAlign>
          <PaddingLeft>2pt</PaddingLeft>
          <PaddingRight>2pt</PaddingRight>
          <PaddingTop>2pt</PaddingTop>
          <PaddingBottom>2pt</PaddingBottom>
        </Style>
      </Textbox>
    </ReportItems>
    <Height>120.6133in</Height>
    <Style>
      <Border>
        <Style>None</Style>
      </Border>
      <BackgroundColor>DarkBlue</BackgroundColor>
    </Style>
  </Body>
  <Width>8.1in</Width>
  <Page>
    <PageHeight>455in</PageHeight>
    <LeftMargin>1in</LeftMargin>
    <RightMargin>1in</RightMargin>
    <TopMargin>1in</TopMargin>
    <BottomMargin>1in</BottomMargin>
    <Style />
  </Page>
  <AutoRefresh>0</AutoRefresh>
  <rd:ReportUnitType>Inch</rd:ReportUnitType>
  <rd:ReportID>ba8d6290-ee16-4704-b4dd-85ba44958980</rd:ReportID>
</Report>