What Lamprey meant is the two options shown below. SQL syntax does not let you use a case expression to choose the type of join as you are attempting to do.---- 1
IF (@INCLUDE_NORUNS@ = 'Y')
BEGIN
-- entire query that uses left join starting with select here
END
ELSE
BEGIN
-- entire query that uses inner join starting with select here
END
--- 2
....
FROM
STTABLE ST
LEFT JOIN LINK AS LT ON LT.LN_ENTITY_ID = ST.ST_ID AND LN.LN_ENTITY_TYPE = 'STEP'
WHERE
@INCLUDE_NORUNS@ = 'Y'
OR
(
LT.LN_ENTITY_ID = ST.ST_ID AND LN.LN_ENTITY_TYPE = 'STEP'
);