• CleverSQLUserID (6/26/2013)


    - obviously produces a different query plan

    The query plan is not the indication that your new-style code is false or correct. Your resultset must be the same with both queries. Your second query looks good to me, but I must admit I'm not familiar with the old-style code.

    Will this code produce the same resultset?SELECT A.recid

    , A.id

    , A.PROCID

    , A.pstatus

    , B.pname

    , B.pdesc

    , LEN(pname) AS plen

    , CASE

    WHEN C.seq IS NULL

    THEN 0

    ELSE 1

    END AS DISABLED

    FROM lprocs A

    INNER JOIN pmaster B

    ON A.PROCID = B.PROCID

    LEFT OUTER JOIN pmap C

    ON C.PROCID = A.PROCID

    AND C.typeid IN (

    SELECT D.typeid

    FROM loan D

    WHERE A.id = D.id

    )

    WHERE A.id = @id

    ORDER BY pname

    ** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **