September 10, 2015 at 9:27 am
I would initially change this:
FROM Dbo.[VDSMeetingInformation] VMI
INNER JOIN dbo.[DelimitedSplit8K](@fund_id,',') fnsplt ON VMI.FundID =(CASE WHEN fnsplt.item IS NULL THEN VMI.FundID ELSE fnsplt.item END)
WHERE VMI.customerID = @customer_id
AND VMI.MeetingDate BETWEEN @Start_date AND @End_date
AND VMI.MeetingID > 0
AND VMI.Country IS NOT NULL
AND (
VMI.CompanyName LIKE COALESCE(@Value1,VMI.CompanyName ) +'%'
OR
VMI.ticker LIKE COALESCE(@Value1,VMI.Ticker)+'%'
OR
VMI.SecurityID LIKE COALESCE(@value1,VMI.SecurityID) +'%'
)
To this:
FROM Dbo.[VDSMeetingInformation] VMI
WHERE VMI.customerID = @customer_id
AND VMI.MeetingDate BETWEEN @Start_date AND @End_date
AND VMI.MeetingID > 0
AND VMI.Country IS NOT NULL
AND (
VMI.CompanyName LIKE @Value1 + '%'
OR
VMI.ticker LIKE @Value1 + '%'
OR
VMI.SecurityID LIKE @value1 + '%'
OR
@value1 IS NULL
)
AND(
EXISTS ( SELECT 1 FROM dbo.[DelimitedSplit8K](@fund_id,',') fnsplt WHERE VMI.FundID = fnsplt.item)
OR
@fund_id IS NULL
)
Viewing post 16 (of 15 total)
You must be logged in to reply to this topic. Login to reply