Third Select statement didn't read
SQL Sentry didn't read the third select statement. Do you know the reason?
The "Result" tab, the query plan executed only the first two select statements.
Here is the entire query:
declare @factorTypeId int; declare @benefitId int; Declare @BenefitExternalID uniqueidentifier = '01BE05C1-503C-44E8-AE0D-D485EBE6BF69' Declare @pdate datetime = '09/17/2014' SET NOCOUNT ON; select @factorTypeId = ft.ID from Rating.FactorType ft where ft.Descr = 'Surcharge'; select @benefitId = b.ID from Rating.Benefit b where b.ExternalID = @pBenefitExternalID; select f.Name, f.Descr, f.[Amount], o.[ShortName], f.[EffectiveDate], f.[ExpirationDate], f.[ExternalID] from [Rating].[Benefit] b join [Rating].[ElementFactor] ef on ef.[BenefitID] = b.[ID] join [Rating].[Element] e on ef.[ElementID] = e.[ID] join [Rating].[Factor] f on ef.[FactorID] = f.[ID] join [Rating].Operation o on o.[ID] = f.[OperationID] where f.FactorTypeID = @factorTypeId and b.ID = @benefitId and (@pDate between f.[EffectiveDate] and isnull(f.[ExpirationDate], '12/31/9999') or f.EffectiveDate > GETDATE())
It works now. I have restarted the SQL Sentry and place the query again and works what I expected.