February 12, 2014 at 7:50 am
Hi Everyone
ProcA Create the temporary table Table1
ProcA call ProcB
ProcB insert into temporary Table1 some values (insert into #Table1 ... select...)
ProcA select values from temporary table1
I can create and valid both proc but when I try to execute procA
I got this error :
Msg 208, Level 16, State 0, Procedure ProcB, Line 23
Invalid object name '#Table1'.
Seems that I can't use #table1 in procB from ProcA
thanks !!
February 12, 2014 at 7:52 am
Should be fine, I've done that before. Can you post the code?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
February 12, 2014 at 8:09 am
while copying my code I see a typo in declaring #table1 into procb. So it's all fine now
thanks
February 17, 2014 at 9:02 am
Personally, I'd advise against sharing temp tables between nested procedures, it can lead to a world of pain.
Our approach is to have a persisted table, create your records in there and assign each set of records a "RuntimeID" of NEWID(). Then you can pass this value betwen procedures and be confident that you're working on the correct set of data.
The benefits of this are that you can opt to automatically clear down data at the end of execution or persist it for debugging and also there's less change of tempDB getting filled.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply