BigJohnson
10-23-2006, 10:53 AM
Pulling my hair out with this one. I'm attempting to place a CASE statement within a WHERE clause so that the query becomes a little dynamic.
With the case removed, the clause works fine, with the CASE statement in place, it fails with a syntax error at the "NOT" part on the first line.
Any ideas?
Thanks.
WHERE (tblDefect.Status <> 'closed') AND (tblDevCom.Dev_Id = @DevID) AND (tblSites.SiteID LIKE @TEMP OR @TEMP IS NULL) AND
(
CASE @EoD
WHEN 'A' THEN (tblDefStd.DefStdDesc NOT LIKE '%End%')
WHEN 'B' THEN (tblDefStd.DefStdDesc LIKE '%End%')
END
)
With the case removed, the clause works fine, with the CASE statement in place, it fails with a syntax error at the "NOT" part on the first line.
Any ideas?
Thanks.
WHERE (tblDefect.Status <> 'closed') AND (tblDevCom.Dev_Id = @DevID) AND (tblSites.SiteID LIKE @TEMP OR @TEMP IS NULL) AND
(
CASE @EoD
WHEN 'A' THEN (tblDefStd.DefStdDesc NOT LIKE '%End%')
WHEN 'B' THEN (tblDefStd.DefStdDesc LIKE '%End%')
END
)