0
我嘗試在sql server的where子句中使用case語句並獲取錯誤消息。where子句中的用例語句
WHERE (PRCA.EDLType = 'E')
AND
(
NOT
(
PRCA.EDLCode IN
(
SELECT EarnCode
FROM dbo.udECforUnionRpt
WHERE (EDL = 'E')
)
)
)
AND (PRCM.udMasterCraft IS NOT NULL)
AND (PRCA.PREndDate BETWEEN @BegPREndDate AND @EndPREndDate)
AND PRCM.udMasterCraft BETWEEN @BegMasterCraft AND @EndMasterCraft
AND PRCA.Class BETWEEN @BegClass AND @EndClass
AND
(
CASE WHEN @ExcludePREAPR='Y' THEN UPPER(PRCA.Class) not like upper('%PREAPR%')
else PRCA.Class
)
END
)
ORDER BY PRCA.PRCo
也許是因爲PRCA.Class有兩個條件?或者我只是不寫CASE聲明權利。
謝謝
什麼是錯誤信息? – StevieG
消息156,級別15,狀態1,過程z_UPSPRUnion_test,行82 關鍵字'like'附近的語法不正確。 –