You can easily do this only with a connection:
SELECT t1.*, t2.* FROM t1 cross join (SELECT * FROM (SELECT top 1 tb10.*, 0 as bCcond src FROM tb10 UNION ALL SELECT top 1 tb11.*, 1 as bCcond src FROM tb11 ) t WHERE @bCond = bCcond ) t2
Doing top before union all should also help the optimizer create a better query plan if the tables are really complex.
In addition, executing top without order by usually not approved. It may return different rows with different calls, but rows are not guaranteed to be random.
source share