<?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="Textbox2">
        <CanGrow>true</CanGrow>
        <KeepTogether>true</KeepTogether>
        <Paragraphs>
          <Paragraph>
            <TextRuns>
              <TextRun>
                <Value>="Required Stored Procedures have been created in the AdminMonitor Database on " &amp; First(Fields!ServerName.Value, "ServerName")</Value>
                <Style>
                  <FontSize>26pt</FontSize>
                  <Color>White</Color>
                </Style>
              </TextRun>
            </TextRuns>
            <Style>
              <TextAlign>Center</TextAlign>
            </Style>
          </Paragraph>
        </Paragraphs>
        <rd:DefaultName>Textbox2</rd:DefaultName>
        <Top>0.3in</Top>
        <Left>0.4125in</Left>
        <Height>2.30834in</Height>
        <Width>5.53334in</Width>
        <Style>
          <Border>
            <Style>None</Style>
          </Border>
          <VerticalAlign>Middle</VerticalAlign>
          <PaddingLeft>2pt</PaddingLeft>
          <PaddingRight>2pt</PaddingRight>
          <PaddingTop>2pt</PaddingTop>
          <PaddingBottom>2pt</PaddingBottom>
        </Style>
      </Textbox>
      <Textbox Name="Textbox1">
        <CanGrow>true</CanGrow>
        <KeepTogether>true</KeepTogether>
        <Paragraphs>
          <Paragraph>
            <TextRuns>
              <TextRun>
                <Value>Back To Deployment Page</Value>
                <Style>
                  <FontSize>22pt</FontSize>
                  <Color>DarkBlue</Color>
                </Style>
              </TextRun>
            </TextRuns>
            <Style>
              <TextAlign>Center</TextAlign>
            </Style>
          </Paragraph>
        </Paragraphs>
        <rd:DefaultName>Textbox1</rd:DefaultName>
        <ActionInfo>
          <Actions>
            <Action>
              <Drillthrough>
                <ReportName>MonitorDeployAdminMonitor</ReportName>
              </Drillthrough>
            </Action>
          </Actions>
        </ActionInfo>
        <Top>2.80833in</Top>
        <Left>0.4125in</Left>
        <Height>0.59167in</Height>
        <Width>5.53334in</Width>
        <ZIndex>1</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>3.58333in</Height>
    <Style>
      <Border>
        <Style>None</Style>
      </Border>
      <BackgroundColor>DarkBlue</BackgroundColor>
    </Style>
  </Body>
  <Width>6.5in</Width>
  <Page>
    <LeftMargin>1in</LeftMargin>
    <RightMargin>1in</RightMargin>
    <TopMargin>1in</TopMargin>
    <BottomMargin>1in</BottomMargin>
    <Style />
  </Page>
  <AutoRefresh>0</AutoRefresh>
  <DataSources>
    <DataSource Name="Local">
      <ConnectionProperties>
        <DataProvider>SQL</DataProvider>
        <ConnectString>Data Source=LocalHost;Initial Catalog=AdminMonitor</ConnectString>
        <IntegratedSecurity>true</IntegratedSecurity>
      </ConnectionProperties>
      <rd:SecurityType>Integrated</rd:SecurityType>
      <rd:DataSourceID>b944baa6-ff7f-435a-a183-014187e6c14c</rd:DataSourceID>
    </DataSource>
    <DataSource Name="LocalHost">
      <ConnectionProperties>
        <DataProvider>SQL</DataProvider>
        <ConnectString>Data Source=LocalHost;Initial Catalog=AdminMonitor</ConnectString>
        <IntegratedSecurity>true</IntegratedSecurity>
      </ConnectionProperties>
      <rd:SecurityType>Integrated</rd:SecurityType>
      <rd:DataSourceID>ee6901f1-030d-4f75-a571-e8aa6b203e75</rd:DataSourceID>
    </DataSource>
  </DataSources>
  <DataSets>
    <DataSet Name="GetPerfDataProc">
      <Query>
        <DataSourceName>LocalHost</DataSourceName>
        <CommandText>IF NOT EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'GetPerfData')
Begin

USE AdminMonitor



EXECUTE sp_executesql   
          N'CREATE 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())'

END</CommandText>
      </Query>
    </DataSet>
    <DataSet Name="GetWaitDataProc">
      <Query>
        <DataSourceName>LocalHost</DataSourceName>
        <CommandText>IF NOT EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'GetWaitTypeData')
begin

USE AdminMonitor



EXECUTE sp_executesql   
          N'CREATE 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())'

END</CommandText>
      </Query>
    </DataSet>
    <DataSet Name="GetReadWriteLatencyProc">
      <Query>
        <DataSourceName>LocalHost</DataSourceName>
        <CommandText>IF NOT EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'GetReadWriteLatency')
Begin

USE AdminMonitor


EXECUTE sp_executesql   
          N'CREATE 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())'

END</CommandText>
      </Query>
    </DataSet>
    <DataSet Name="AvailableMemory">
      <Query>
        <DataSourceName>LocalHost</DataSourceName>
        <CommandText>IF NOT EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'GetWindowsCountersAvailableMem')
BEGIN

USE AdminMonitor



EXECUTE sp_executesql   
          N'CREATE 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())'


Select * from sysdatabases

END</CommandText>
      </Query>
      <Fields>
        <Field Name="name">
          <DataField>name</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="dbid">
          <DataField>dbid</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
        <Field Name="sid">
          <DataField>sid</DataField>
          <rd:TypeName>System.Byte[]</rd:TypeName>
        </Field>
        <Field Name="mode">
          <DataField>mode</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
        <Field Name="status">
          <DataField>status</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="status2">
          <DataField>status2</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="crdate">
          <DataField>crdate</DataField>
          <rd:TypeName>System.DateTime</rd:TypeName>
        </Field>
        <Field Name="reserved">
          <DataField>reserved</DataField>
          <rd:TypeName>System.DateTime</rd:TypeName>
        </Field>
        <Field Name="category">
          <DataField>category</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="cmptlevel">
          <DataField>cmptlevel</DataField>
          <rd:TypeName>System.Byte</rd:TypeName>
        </Field>
        <Field Name="filename">
          <DataField>filename</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="version">
          <DataField>version</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
      </Fields>
    </DataSet>
    <DataSet Name="DiskRead">
      <Query>
        <DataSourceName>LocalHost</DataSourceName>
        <CommandText>IF NOT EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'GetWindowsCountersAvgDiskRead')
BEGIN

USE AdminMonitor

EXECUTE sp_executesql   
          N'CREATE 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())'


Select * from sysdatabases

END</CommandText>
      </Query>
      <Fields>
        <Field Name="name">
          <DataField>name</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="dbid">
          <DataField>dbid</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
        <Field Name="sid">
          <DataField>sid</DataField>
          <rd:TypeName>System.Byte[]</rd:TypeName>
        </Field>
        <Field Name="mode">
          <DataField>mode</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
        <Field Name="status">
          <DataField>status</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="status2">
          <DataField>status2</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="crdate">
          <DataField>crdate</DataField>
          <rd:TypeName>System.DateTime</rd:TypeName>
        </Field>
        <Field Name="reserved">
          <DataField>reserved</DataField>
          <rd:TypeName>System.DateTime</rd:TypeName>
        </Field>
        <Field Name="category">
          <DataField>category</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="cmptlevel">
          <DataField>cmptlevel</DataField>
          <rd:TypeName>System.Byte</rd:TypeName>
        </Field>
        <Field Name="filename">
          <DataField>filename</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="version">
          <DataField>version</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
      </Fields>
    </DataSet>
    <DataSet Name="ServerName">
      <Query>
        <DataSourceName>LocalHost</DataSourceName>
        <CommandText>Select @@servername AS 'ServerName'</CommandText>
      </Query>
      <Fields>
        <Field Name="ServerName">
          <DataField>ServerName</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
      </Fields>
    </DataSet>
    <DataSet Name="DiskWrite">
      <Query>
        <DataSourceName>LocalHost</DataSourceName>
        <CommandText>IF NOT EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'GetWindowsCountersAvgDiskWrite')
BEGIN

USE AdminMonitor

EXECUTE sp_executesql   
          N'CREATE 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())'


Select * from sysdatabases

END</CommandText>
      </Query>
      <Fields>
        <Field Name="name">
          <DataField>name</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="dbid">
          <DataField>dbid</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
        <Field Name="sid">
          <DataField>sid</DataField>
          <rd:TypeName>System.Byte[]</rd:TypeName>
        </Field>
        <Field Name="mode">
          <DataField>mode</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
        <Field Name="status">
          <DataField>status</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="status2">
          <DataField>status2</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="crdate">
          <DataField>crdate</DataField>
          <rd:TypeName>System.DateTime</rd:TypeName>
        </Field>
        <Field Name="reserved">
          <DataField>reserved</DataField>
          <rd:TypeName>System.DateTime</rd:TypeName>
        </Field>
        <Field Name="category">
          <DataField>category</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="cmptlevel">
          <DataField>cmptlevel</DataField>
          <rd:TypeName>System.Byte</rd:TypeName>
        </Field>
        <Field Name="filename">
          <DataField>filename</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="version">
          <DataField>version</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
      </Fields>
    </DataSet>
    <DataSet Name="CacheHitRatio">
      <Query>
        <DataSourceName>LocalHost</DataSourceName>
        <CommandText>IF NOT EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'GetWindowsCountersCacheHitRatio')

BEGIN

USE AdminMonitor

EXECUTE sp_executesql   
          N'CREATE 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())'


Select * from sysdatabases

END</CommandText>
      </Query>
      <Fields>
        <Field Name="name">
          <DataField>name</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="dbid">
          <DataField>dbid</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
        <Field Name="sid">
          <DataField>sid</DataField>
          <rd:TypeName>System.Byte[]</rd:TypeName>
        </Field>
        <Field Name="mode">
          <DataField>mode</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
        <Field Name="status">
          <DataField>status</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="status2">
          <DataField>status2</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="crdate">
          <DataField>crdate</DataField>
          <rd:TypeName>System.DateTime</rd:TypeName>
        </Field>
        <Field Name="reserved">
          <DataField>reserved</DataField>
          <rd:TypeName>System.DateTime</rd:TypeName>
        </Field>
        <Field Name="category">
          <DataField>category</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="cmptlevel">
          <DataField>cmptlevel</DataField>
          <rd:TypeName>System.Byte</rd:TypeName>
        </Field>
        <Field Name="filename">
          <DataField>filename</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="version">
          <DataField>version</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
      </Fields>
    </DataSet>
    <DataSet Name="PageFileUsage">
      <Query>
        <DataSourceName>LocalHost</DataSourceName>
        <CommandText>IF NOT EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'GetWindowsCountersPageFileUsage')
BEGIN

USE AdminMonitor

EXECUTE sp_executesql   
          N'CREATE 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())'


Select * from sysdatabases

END</CommandText>
      </Query>
      <Fields>
        <Field Name="name">
          <DataField>name</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="dbid">
          <DataField>dbid</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
        <Field Name="sid">
          <DataField>sid</DataField>
          <rd:TypeName>System.Byte[]</rd:TypeName>
        </Field>
        <Field Name="mode">
          <DataField>mode</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
        <Field Name="status">
          <DataField>status</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="status2">
          <DataField>status2</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="crdate">
          <DataField>crdate</DataField>
          <rd:TypeName>System.DateTime</rd:TypeName>
        </Field>
        <Field Name="reserved">
          <DataField>reserved</DataField>
          <rd:TypeName>System.DateTime</rd:TypeName>
        </Field>
        <Field Name="category">
          <DataField>category</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="cmptlevel">
          <DataField>cmptlevel</DataField>
          <rd:TypeName>System.Byte</rd:TypeName>
        </Field>
        <Field Name="filename">
          <DataField>filename</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="version">
          <DataField>version</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
      </Fields>
    </DataSet>
    <DataSet Name="ProcessorTime">
      <Query>
        <DataSourceName>LocalHost</DataSourceName>
        <CommandText>IF NOT EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'GetWindowsCountersProcessorTime')
BEGIN

USE AdminMonitor

EXECUTE sp_executesql   
          N'CREATE 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())'


Select * from sysdatabases

END</CommandText>
      </Query>
      <Fields>
        <Field Name="name">
          <DataField>name</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="dbid">
          <DataField>dbid</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
        <Field Name="sid">
          <DataField>sid</DataField>
          <rd:TypeName>System.Byte[]</rd:TypeName>
        </Field>
        <Field Name="mode">
          <DataField>mode</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
        <Field Name="status">
          <DataField>status</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="status2">
          <DataField>status2</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="crdate">
          <DataField>crdate</DataField>
          <rd:TypeName>System.DateTime</rd:TypeName>
        </Field>
        <Field Name="reserved">
          <DataField>reserved</DataField>
          <rd:TypeName>System.DateTime</rd:TypeName>
        </Field>
        <Field Name="category">
          <DataField>category</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="cmptlevel">
          <DataField>cmptlevel</DataField>
          <rd:TypeName>System.Byte</rd:TypeName>
        </Field>
        <Field Name="filename">
          <DataField>filename</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="version">
          <DataField>version</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
      </Fields>
    </DataSet>
    <DataSet Name="ProcessorQueueLength">
      <Query>
        <DataSourceName>LocalHost</DataSourceName>
        <CommandText>IF NOT EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'GetWindowsCountersProcessorQueueLength')
begin

USE AdminMonitor

EXECUTE sp_executesql   
          N'CREATE 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())'


Select * from sysdatabases

END</CommandText>
      </Query>
      <Fields>
        <Field Name="name">
          <DataField>name</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="dbid">
          <DataField>dbid</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
        <Field Name="sid">
          <DataField>sid</DataField>
          <rd:TypeName>System.Byte[]</rd:TypeName>
        </Field>
        <Field Name="mode">
          <DataField>mode</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
        <Field Name="status">
          <DataField>status</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="status2">
          <DataField>status2</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="crdate">
          <DataField>crdate</DataField>
          <rd:TypeName>System.DateTime</rd:TypeName>
        </Field>
        <Field Name="reserved">
          <DataField>reserved</DataField>
          <rd:TypeName>System.DateTime</rd:TypeName>
        </Field>
        <Field Name="category">
          <DataField>category</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="cmptlevel">
          <DataField>cmptlevel</DataField>
          <rd:TypeName>System.Byte</rd:TypeName>
        </Field>
        <Field Name="filename">
          <DataField>filename</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="version">
          <DataField>version</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
      </Fields>
    </DataSet>
    <DataSet Name="DeadLockCount">
      <Query>
        <DataSourceName>LocalHost</DataSourceName>
        <CommandText>IF NOT EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'GetDeadLockCount')
Begin

USE AdminMonitor


EXECUTE sp_executesql   
          N'CREATE 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'

Select * from sysdatabases

END</CommandText>
      </Query>
      <Fields>
        <Field Name="name">
          <DataField>name</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="dbid">
          <DataField>dbid</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
        <Field Name="sid">
          <DataField>sid</DataField>
          <rd:TypeName>System.Byte[]</rd:TypeName>
        </Field>
        <Field Name="mode">
          <DataField>mode</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
        <Field Name="status">
          <DataField>status</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="status2">
          <DataField>status2</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="crdate">
          <DataField>crdate</DataField>
          <rd:TypeName>System.DateTime</rd:TypeName>
        </Field>
        <Field Name="reserved">
          <DataField>reserved</DataField>
          <rd:TypeName>System.DateTime</rd:TypeName>
        </Field>
        <Field Name="category">
          <DataField>category</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="cmptlevel">
          <DataField>cmptlevel</DataField>
          <rd:TypeName>System.Byte</rd:TypeName>
        </Field>
        <Field Name="filename">
          <DataField>filename</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="version">
          <DataField>version</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
      </Fields>
    </DataSet>
    <DataSet Name="DeadLockDetail">
      <Query>
        <DataSourceName>LocalHost</DataSourceName>
        <CommandText>IF NOT EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'GetDeadLockDetail')
BEGIN

USE AdminMonitor

EXECUTE sp_executesql   
          N'
CREATE 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]'

Select * from Sysdatabases

END</CommandText>
      </Query>
      <Fields>
        <Field Name="name">
          <DataField>name</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="dbid">
          <DataField>dbid</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
        <Field Name="sid">
          <DataField>sid</DataField>
          <rd:TypeName>System.Byte[]</rd:TypeName>
        </Field>
        <Field Name="mode">
          <DataField>mode</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
        <Field Name="status">
          <DataField>status</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="status2">
          <DataField>status2</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="crdate">
          <DataField>crdate</DataField>
          <rd:TypeName>System.DateTime</rd:TypeName>
        </Field>
        <Field Name="reserved">
          <DataField>reserved</DataField>
          <rd:TypeName>System.DateTime</rd:TypeName>
        </Field>
        <Field Name="category">
          <DataField>category</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="cmptlevel">
          <DataField>cmptlevel</DataField>
          <rd:TypeName>System.Byte</rd:TypeName>
        </Field>
        <Field Name="filename">
          <DataField>filename</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="version">
          <DataField>version</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
      </Fields>
    </DataSet>
    <DataSet Name="BlockingCount">
      <Query>
        <DataSourceName>LocalHost</DataSourceName>
        <CommandText>IF NOT EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'GetBlockingCount')

begin

USE AdminMonitor


EXECUTE sp_executesql   
          N'CREATE 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'

Select * from sysdatabases

END</CommandText>
      </Query>
      <Fields>
        <Field Name="name">
          <DataField>name</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="dbid">
          <DataField>dbid</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
        <Field Name="sid">
          <DataField>sid</DataField>
          <rd:TypeName>System.Byte[]</rd:TypeName>
        </Field>
        <Field Name="mode">
          <DataField>mode</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
        <Field Name="status">
          <DataField>status</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="status2">
          <DataField>status2</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="crdate">
          <DataField>crdate</DataField>
          <rd:TypeName>System.DateTime</rd:TypeName>
        </Field>
        <Field Name="reserved">
          <DataField>reserved</DataField>
          <rd:TypeName>System.DateTime</rd:TypeName>
        </Field>
        <Field Name="category">
          <DataField>category</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="cmptlevel">
          <DataField>cmptlevel</DataField>
          <rd:TypeName>System.Byte</rd:TypeName>
        </Field>
        <Field Name="filename">
          <DataField>filename</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="version">
          <DataField>version</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
      </Fields>
    </DataSet>
    <DataSet Name="BlockingDetail">
      <Query>
        <DataSourceName>LocalHost</DataSourceName>
        <CommandText>IF NOT EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'GetBlockingDetail')
Begin


USE AdminMonitor


EXECUTE sp_executesql   
          N'CREATE 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]'

Select * from sysdatabases

END</CommandText>
      </Query>
      <Fields>
        <Field Name="name">
          <DataField>name</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="dbid">
          <DataField>dbid</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
        <Field Name="sid">
          <DataField>sid</DataField>
          <rd:TypeName>System.Byte[]</rd:TypeName>
        </Field>
        <Field Name="mode">
          <DataField>mode</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
        <Field Name="status">
          <DataField>status</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="status2">
          <DataField>status2</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="crdate">
          <DataField>crdate</DataField>
          <rd:TypeName>System.DateTime</rd:TypeName>
        </Field>
        <Field Name="reserved">
          <DataField>reserved</DataField>
          <rd:TypeName>System.DateTime</rd:TypeName>
        </Field>
        <Field Name="category">
          <DataField>category</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="cmptlevel">
          <DataField>cmptlevel</DataField>
          <rd:TypeName>System.Byte</rd:TypeName>
        </Field>
        <Field Name="filename">
          <DataField>filename</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="version">
          <DataField>version</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
      </Fields>
    </DataSet>
    <DataSet Name="GetServerActivity">
      <Query>
        <DataSourceName>Local</DataSourceName>
        <CommandText>IF NOT EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'GetServerActivity')
Begin

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

END</CommandText>
      </Query>
      <Fields>
        <Field Name="name">
          <DataField>name</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="dbid">
          <DataField>dbid</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
        <Field Name="sid">
          <DataField>sid</DataField>
          <rd:TypeName>System.Byte[]</rd:TypeName>
        </Field>
        <Field Name="mode">
          <DataField>mode</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
        <Field Name="status">
          <DataField>status</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="status2">
          <DataField>status2</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="crdate">
          <DataField>crdate</DataField>
          <rd:TypeName>System.DateTime</rd:TypeName>
        </Field>
        <Field Name="reserved">
          <DataField>reserved</DataField>
          <rd:TypeName>System.DateTime</rd:TypeName>
        </Field>
        <Field Name="category">
          <DataField>category</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="cmptlevel">
          <DataField>cmptlevel</DataField>
          <rd:TypeName>System.Byte</rd:TypeName>
        </Field>
        <Field Name="filename">
          <DataField>filename</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="version">
          <DataField>version</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
      </Fields>
    </DataSet>
    <DataSet Name="DatabaseGrowth">
      <Query>
        <DataSourceName>Local</DataSourceName>
        <CommandText>IF NOT EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'GetDatabaseGrowth')
BEGIN

USE AdminMonitor

EXECUTE sp_executesql   
          N'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())'


Select * from sysdatabases

END</CommandText>
      </Query>
      <Fields>
        <Field Name="name">
          <DataField>name</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="dbid">
          <DataField>dbid</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
        <Field Name="sid">
          <DataField>sid</DataField>
          <rd:TypeName>System.Byte[]</rd:TypeName>
        </Field>
        <Field Name="mode">
          <DataField>mode</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
        <Field Name="status">
          <DataField>status</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="status2">
          <DataField>status2</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="crdate">
          <DataField>crdate</DataField>
          <rd:TypeName>System.DateTime</rd:TypeName>
        </Field>
        <Field Name="reserved">
          <DataField>reserved</DataField>
          <rd:TypeName>System.DateTime</rd:TypeName>
        </Field>
        <Field Name="category">
          <DataField>category</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="cmptlevel">
          <DataField>cmptlevel</DataField>
          <rd:TypeName>System.Byte</rd:TypeName>
        </Field>
        <Field Name="filename">
          <DataField>filename</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="version">
          <DataField>version</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
      </Fields>
    </DataSet>
    <DataSet Name="QueryTimeOutbyDateRange">
      <Query>
        <DataSourceName>Local</DataSourceName>
        <CommandText>
IF NOT EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'GetQueryTimeOutsHourlyCount')
BEGIN

USE AdminMonitor

EXECUTE sp_executesql   
          N'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)
'


Select * from sysdatabases

END</CommandText>
      </Query>
      <Fields>
        <Field Name="name">
          <DataField>name</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="dbid">
          <DataField>dbid</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
        <Field Name="sid">
          <DataField>sid</DataField>
          <rd:TypeName>System.Byte[]</rd:TypeName>
        </Field>
        <Field Name="mode">
          <DataField>mode</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
        <Field Name="status">
          <DataField>status</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="status2">
          <DataField>status2</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="crdate">
          <DataField>crdate</DataField>
          <rd:TypeName>System.DateTime</rd:TypeName>
        </Field>
        <Field Name="reserved">
          <DataField>reserved</DataField>
          <rd:TypeName>System.DateTime</rd:TypeName>
        </Field>
        <Field Name="category">
          <DataField>category</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="cmptlevel">
          <DataField>cmptlevel</DataField>
          <rd:TypeName>System.Byte</rd:TypeName>
        </Field>
        <Field Name="filename">
          <DataField>filename</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="version">
          <DataField>version</DataField>
          <rd:TypeName>System.Int16</rd:TypeName>
        </Field>
      </Fields>
    </DataSet>
  </DataSets>
  <rd:ReportUnitType>Inch</rd:ReportUnitType>
  <rd:ReportID>d2af5768-ba54-4294-965c-f86bca883c0a</rd:ReportID>
</Report>