Greetings All,
Not sure if this is the correct forum for this but I have the following
query I need to get to work but for a SQL report but I can not convert
string 5 to an integer. Is there a way to make this work? I need to
compute in MB how much space the log files are using. Many thanks in
advance for your help.

______________


--Get UTC Time
declare @UTCtd AS datetime
set @UTCtd = getutcdate()

--Get Today's Date and Time
declare @TodayTD AS datetime

set @TodayTD = GETDATE()

--Get Time Zone Informaiton
declare @TimeDif as int
set @TimeDif = DATEDIFF(hh, getutcdate(), getdate())

select distinct
dhused.DataID,
o.Name,
o.ObjID,
o.RootMachineObjID,
ltrim(rtrim(dhused.MachineName)) as MachineName,
o.Status,
dhused.Status as DataStatus,
dhused.Legend,
DATEADD (HH,@TimeDif,dbo.fnSQLDateTime (dhused.ModificationTime)) as
DateLastVal,
--The Math is (Current Date) - (Dataheader.ModificationTime) =
DataAgeMinutes
DATEDIFF(mi, @TodayTD, (DATEADD (HH,@TimeDif,dbo.fnSQLDateTime
(dhused.ModificationTime)))) as DataAgeMinutes,
dhallocated.LastVal as CurrentAllocated,
dhused.LastVal as CurrentUsed,
CONVERT(INT,rtrim(ltrim(replace(o.String5, ' MB', '')))) as
LogFileSize,
dhlogused.LastVal as LogusedPercent,
dhused.Interval,
DATEADD(ss, dhused.Interval,DATEADD (HH,@TimeDif,dbo.fnSQLDateTime
(dhused.ModificationTime))) as NextCheck

from
dbo.Object as o WITH (NOLOCK)
join dbo.Dataheader as dhused on o.ObjID = dhused.ObjID
join dbo.DataHeader as dhallocated on o.ObjID = dhallocated.ObjID
join dbo.DataHeader as dhlogused on o.ObjID = dhlogused.ObjID
where
dhused.KPName like '%DBSTATS'
and
dhused.Legend like '%Current Used%'
and
dhallocated.Legend like '%Current Allocated%'
and
dhlogused.Legend like '%Log Utilization%'
and
dhused.Status <> 134217728


--
abel5405
------------------------------------------------------------------------
abel5405's Profile: https://forums.netiq.com/member.php?userid=5035
View this thread: https://forums.netiq.com/showthread.php?t=55303