• I think EXISTS would be the clearest indication that you just want to know if a matching row exists, not retrieve data from that row. For example:

    SELECT

    p.ProductID, CASE WHEN EXISTS(SELECT 1 FROM @ProductRelation pr

    WHERE p.ProductID IN (pr.FirstProductID, pr.SecondProductID))

    THEN 'Linked' ELSE 'Not Linked' END

    FROM @product p

    ORDER BY

    p.ProductID

    I suspect this also might perform better on large table(s), but I prefer it just as much for the clarity of showing what's actually being looked for.

    Edit: Reformatted the EXISTS() to fit better in the code window.

    SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.