'SQL Server : select from stored procedure

Currently, this is the only way I know

Create @tempTable1

Insert into @tempTable1
    Exec mySP1 input1, input2

Create @tempTable2

Insert into @tempTable2
    Exec mySP2 input1, input2

Select *
from @tempTable1 as A
join @tempTable2 as B on A.input1 = B.input1

Which is very inconvenient because first I would have to create barebone temp tables then insert into, once finished I must remove temp tables. Is there a better way to for me to do something like this instead?

Select * 
from (Exec mySP1 input1, input2) as A
join (Exec mySP2 input1, input2) as B on A.input1 = B.input1


Solution 1:[1]

https://blog.sqlauthority.com/2022/02/08/sql-server-using-stored-procedure-in-select-statement/

Not sure why this blog didn't show up at work today but I'm going to print this out and try it out on Monday.

SELECT *
FROM OPENROWSET('SQLNCLI',
'server=localhost;trusted_connection=yes;',
'EXEC Exec mySP1 input1, input2') as A
join
OPENROWSET('SQLNCLI',
'server=localhost;trusted_connection=yes;',
'EXEC Exec mySP2 input1, input2') as B on A.input1 = B.input1

Any comment ?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Syntax_MM