Instead query like this:
SELECT TOP 1 * FROM Customers c (NOLOCK) WHERE Key = (mykey)
AND NOT EXISTS (SELECT 0 FROM Invoices i (NOLOCK) WHERE i.key = c.key AND i.Date > GETDATE() )
try to use this syntax:
select * from Customers inner join (select top 1 PK from ... order by ..) X on Customers.PK = X.PK
Usually it will behave better than select top 1 * from ...
No comments:
Post a Comment