Link to home
Start Free TrialLog in
Avatar of countrymeister
countrymeister

asked on

Creation of Temporary tables in T-sql

I would like to know whether I should create temporary tables in the main procedure or in the called procedure, and please state your reasons why.
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Please state your programming needs, as that will dicate the use or not use of temporary tables, and not whatever I believe.
The scope of a temp table can only go down, not up.  So if you think you might need the data in the calling procedure, create it there.  It can be referenced and populated by any procedure in the procedure call stack at that point.
Avatar of countrymeister
countrymeister

ASKER

jimhorn

I have a main procedure which gathers data from the database and makes call to  another four procedures. In one of those four procedures I need to load data into a temporary table which is then used further down by another two procedures for calculatioion and data manipulation.

All the execs for the four procs are done from the main proc.
ASKER CERTIFIED SOLUTION
Avatar of BrandonGalderisi
BrandonGalderisi
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial