hi,
Thanks for u r extreme help in advance, please help me in optimizing the below query, the table names are highlighted which are
ETLDailyLoad,Dimdate,ETLAggregationconfiguration,ETLHourlyOMSLoad
UPDATE TOP(10) ETLDailyLoad
SET ETLStatus = 'Running',
ETLStartTime = GETDATE()
OUTPUT
inserted.DimDateID,
inserted.DimMonthID,
inserted.SwitchClliCode,
cast(inserted.ETLDailyLoadID as varchar) EtlDailyLoadID,
inserted.SWVersionID,
inserted.DataLoaded_Percent,
inserted.ElementLevel
--select a.*
FROM ETLDailyLoad a with (nolock)
INNER JOIN DimDate (NOLOCK) ON a.DimDateID =Convert(Varchar(10),sqldate,112)
CROSS JOIN (select AggBackVerification,AggThreshold from ETLAggregationConfiguration (NOLOCK) C
where c.tablename='FactDaily1xDOBscRack') C
where (DimDate.SQLDate between cast(convert(varchar(10),getdate() - C.AggBackVerification,101) as smalldatetime) and cast(convert(varchar(10),getdate() - 1,101)as smalldatetime))
and ElementLevel = 'Aggr-L'
and ETLStatus != 'Complete'
and ( [ETLSTATUS] is null or [ETLSTATUS] in('Queued'))
and (select COUNT(dimdateid) from ETLHourlyOMSLoad (NOLOCK)
WHERE DimDateID =20130415 and SwitchClliCode ='ALBYNYKJ00W'
and ETLStatus = 'complete')* 1.0 /24 >= C.AggThreshold
and (select COUNT(dimdateid) from ETLHourlyOMSLoad (NOLOCK)
WHERE DimDateID = a.DimDateID and SwitchClliCode = a.SwitchClliCode
-- WHERE DimDateID =20130415 and SwitchClliCode ='ALBYNYKJ00W'
and ETLStatus = 'complete')* 1.0 /24 > a.DataLoaded_Percent
Thanks&Regards
Kumar