• You can't use CASE to determine whether the join will be LEFT JOIN or INNER JOIN if that's what you were asking.

    You probably could use additional conditions in WHERE clause to achieve similar effect, but IMHO your solution with IF and two separate blocks of code is better. See the code below for how that could be done (the idea is tested and works, but you may need to modify it for your environment - you didn't explain much about the @innerjoin parameter, so I wrote it as if it was varchar with values "Yes" or "No").

    SELECT *

    FROM tableA ta

    LEFT JOIN tableB tb ON tb.idA=ta.idA

    LEFT JOIN tableC tc ON tc.idB=tb.idB

    WHERE ta.param1 = @param1

    AND ta.param2 = @param2

    AND (tb.idA=ta.idA OR @innerjoin = 'No')

    AND (tc.idB=tb.idB OR @innerjoin = 'No')

    Edit: To be correct, the way I wrote it, any other value for @innerjoin than 'No' will cause that the query will perform as inner joined.