create table t1(f1 int,f2 int,f3 int)
insert t1 select 1,2,3create table t2(id int,value int)
insert t2 select 1,10
union select 2,20declare @value1 int,@value2 int
select @value1=value from t2 where id=1
select @value2=value from t2 where id=2exec('select *,null ['+@value1+'],null ['+@value2+'] from t1')drop table t1,t2