select a,b,c into #tmp1 from table1 where name=@parm1
insert into #tmp1 select d,e,f from table2 where id=@parm2
insert into #tmp1 select g,h,i from table3 where id=5
select * from #tmp1
CREATE PROCEDURE GetRecords(
@parm1 varchar(50),
@parm2 int
)
AS
BEGIN
DECLARE @a varchar(50),
@b varchar(50),
@c varchar(50),
@d varchar(50),
@e varchar(50),
@f varchar(50),
@g varchar(50),
@h varchar(50),
@i varchar(50)
SELECT @a = a, @b = b, @c = c
FROM table1
WHERE name = @parm1
SELECT @d = d, @e = e, @f = f
FROM table2
WHERE id = @parm2
SELECT @g = g, @h = h, @i = i
FROM table3
WHERE id = 5
SELECT a = @a, b = @b, c = @c, d = @d, e = @e, f = @f, g = @g, h = @h, i = @i
END
select top 20 a,b,c into #tmp1 from table1 where name=@parm1
insert into #tmp1 select top 20 d,e,f from table2 where id=@parm2
insert into #tmp1 select top 20 g,h,i from table3 where id=5
select * from #tmp1