Good Day
All we are trying to do is inside a trigger make sure the user is not inserting two fees that have 'alone' in the name. Those fees need to be handled individually.
For some reason, it appears the top section of sql quit working two weeks ago. To get around it I recoded it the second way and get the correct results. What I am confused is why would the first portion seemed to have worked for the last several years and now it does not?
SELECT @AloneRecordCount = count(*)
FROM inserted i
INNER JOIN deleted d on i.id = d.id
WHERE i.StatusID = 32
AND d.StatusID <> 32
AND i.id IN
(SELECT settlementid FROM vwFundingDisbursement fd
WHERE fd.DisbTypeName LIKE '%Alone'
AND fd.PaymentMethodID = 0)
SELECT @AloneRecordCount = count(i.id)
FROM inserted i INNER JOIN
deleted d on i.id = d.id
JOIN vwFundingDisbursement fd on i.id = fd.settlementid
WHERE i.StatusID = 32
AND d.StatusID <> 32
AND fd.DisbTypeName like '%Alone'
AND fd.PaymentMethodID = 0
this is on SQL Server 2005
there is no error, instead the top statement will only return 1 or zero
while the bottom statement will return the actual number found.