I have two procedures – two huge sets of selects with several sub-select and unions.
I need to union results from these procedures and I still need them to exists separately.
Something like that:
if @Param = 1 Then
PROCEDURE1
if @Param = 2 THEN
PROCEDURE2
if @Param = 3 Then
PROCEDURE1 union PROCEDURE2
I read that it’s impossible to have union on procedures and I can’t use temporary tables.
Any idea?
You can convert the procedures to views.
OR
You can exec the procedures into a temp table, and then exec the other one into the same temp table: