I have a Notes
table with a uniqueidentifier
column that I use as a FK for a variety of other tables in the database (don\'t worry, the uniqu
The UNION ALL
version would probably be satisfied quite easily by 2 index seeks. OR
can lead to scans. What do the execution plans look like?
Also have you tried this to avoid accessing Notes
twice?
;WITH J AS
(
SELECT UniqueID FROM Leads WHERE LeadID = @LeadID
UNION ALL
SELECT UniqueID FROM Quotes WHERE LeadID = @LeadID
)
SELECT N.* /*Don't use * though!*/
FROM Notes N
JOIN J ON N.TargetUniqueID = J.UniqueID