Question : Help on Stored Procedure

Hello Experts,
I wanted to create an Main Stored Procedure (MAIN_SP) which creates a final table after invoking two different stored procedures (PROC1 and PROC2).
In short:
When MAIN_SP is executed, It invokes ....

 The first procedure (PROC1) which uses values (DSTRecID, DSTCountryID)  from DBO.TMP_TBL1 and stores output to DBO.PROC1_TBL (Table)

...Then...

The second procedure(PROC2) which uses value(CountryID) from DBO.COUNTRY where CountryID NOT IN TMP_TBL1.DSTCountryID. and stores output to DB.PROC2_TBL(Table)...

...Then...
Cross Join DBO.PROC1_TBL and  DBO.PROC2_TBL INTO DBO.FINAL_TABLE...

...Then the final Step....

 DROP TABLE DB.PROC1_TBL
 DROP TABLE DB.PROC2_TBL

My Source TABLES are
DBO.TMP_TBL1 (Table is dynamic, the number of records varies in any given time. This is populated by a daily process)
DSTRecID   DSTCountryID
10                   AUS
11                   AUS
21                   USA
13                   GER
11                   CHN          
...

DBO.COUNTRY (Table is static)
CountryID           COUNTRY
ARU                        Aruba
AUS                        Australia
BEL                         Belgium
BRI                          Britain
CAN                       Canada
CHN                       China                  
FRA                        France  
FIN                         Finland
GER                        Germany
ICE                          Iceland

Is this possible? Can anyone guide me on the basic syntax.

Cheers,
Jackson

Answer : Help on Stored Procedure

I think this might be a littlle easier than you realized -- you can do a union between the two temp tables and call it done:
-- Here is the contents of your final table ...
Select Col1      Col2      Col3      Col4      Col5      Col6      Col7      DSTRecID      Country
from DBO.PROC1_TBL
union
select Col1      Col2      Col3      Col4      Col5      Col6      Col7      DSTRecID      Country
from DBO.PROC2_TBL

-- You can insert it into your final table as:
Insert into dbo.final_table (Col1      Col2      Col3      Col4      Col5      Col6      Col7      DSTRecID      Country )
Select Col1      Col2      Col3      Col4      Col5      Col6      Col7      DSTRecID      Country
from DBO.PROC1_TBL
union
select Col1      Col2      Col3      Col4      Col5      Col6      Col7      DSTRecID      Country
from DBO.PROC2_TBL


Random Solutions  
 
programming4us programming4us