I would like a bit better understanding of the #Temptable scope across stored procedures within one session. My understanding is that #TempTable has local scope to the current session where it has been created. What I am after is to create a temp table in a store procedure 1, then fill it in another sp2 which I will call from within sp 1. This way I will have full table to work with in sp1(data filled in sp2). Now it seems to work fine, however I am not sure if there are any hidden problems which I may see. Any one have any idea? The reason I am using this approach is that I can not use insert exec nested statements (sp2 already calls insert into exec). Thanks in advance Following is sample of my code logic for clarification of question
create table #TempToBeFilledInAnotherSp(
col1 int,
col2 int
);
exec spe2 param1, param2;--this sp will insert data in #TempToBeFilledInAnotherSp
--Now that I have all the data in temp table which I created here I can use it
select * from #TempToBeFilledInAnotherSp;--or do my further processing on the data