I'm looking at sprocs right now that seem to follow the behavior demonstrated below
DECLARE @tablevar TABLE
(
FIELD1 int,
FIELD2 int,
FIELD3 varchar(50),
-- etc
)
INSERT INTO @tablevar
(
FIELD1,
FIELD2,
FIELD3,
-- etc
)
SELECT FIELD1, FIELD2, FIELD3, -- etc
FROM
TableA Inner Join TableB on TableA.Foo = TableB.Foo
Inner Join TableC on TableB.Bar = TableC.Bar
-- Where, Order By, etc.
Select FIELD1, FIELD2, FIELD3, -- etc
FROM @tablevar
Is there a benefit to using this approach as opposed to using a plain select statement and skipping the table variable?