SELECT
S.ORDER_NO ,
I.ODNO
FROM PMSETORDER AS S
LEFT JOIN POITEM AS I ON S.ORDER_NO = I.ORDER_NO
WHERE S.ORDER_NO = @P1
OR i.odno = @P2
從 DMV 抓出傳入的參數值是派工單號,然後更神奇的事情是,Odno 欄位是訂單編號,永遠不會成立的 WHERE 條件,Orz
修正 TSQL,把 Odno 條件拿掉
SELECT
S.ORDER_NO ,
I.ODNO
FROM PMSETORDER AS S
LEFT JOIN POITEM AS I ON S.ORDER_NO = I.ORDER_NO
WHERE S.ORDER_NO = @P1
執行計畫比較
沒有留言:
張貼留言