Hi Mukesh,
I Do not know whether its optimal solution or not,
but for sure this will work for
You can compose the query like the one below
DECLARE @query VARCHAR(MAX);
SET @query = 'SELECT * FROM table1 INNER JOIN ';
SELECT @ID = ID FROM table1 WHERE BLAH-BLAH = BLAH-BLAH;
IF (@ID = 1)
SET @query += 'table2 ';
else
SET @query += 'table3 ';
SET @query += 'ON tbljoin.id=table1.id';
exec(@query);
Hope this help you a bit.
Regards,
RK