Is it possible to have a conditional join based on parameter; for example:
//PSEUDE CODE:
DECLARE @condition bit
SET @condition=1 or 0
SELECT *
FROM tableA
INNER JOIN tableB on tableA.SomeColumn = tableB.SomeColumn
if @condition = 0 THEN
INNER JOIN tableC ON tableC.SomeCOlumn = TableA.SomeColumn
ELSE
INNER JOIN tableD ON tableD.SomeColumn=TableA.someColumn
Thank you
Description
You can build a varchar containing your query and use
execto execute them.Sample
More Information