Solved

Creation of Temporary tables in T-sql

Posted on 2008-10-02
4
487 Views
Last Modified: 2012-05-05
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.
0
Comment
Question by:countrymeister
  • 2
4 Comments
 
LVL 65

Expert Comment

by:Jim Horn
ID: 22628664
Please state your programming needs, as that will dicate the use or not use of temporary tables, and not whatever I believe.
0
 
LVL 39

Expert Comment

by:BrandonGalderisi
ID: 22628673
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.
0
 
LVL 1

Author Comment

by:countrymeister
ID: 22628951
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.
0
 
LVL 39

Accepted Solution

by:
BrandonGalderisi earned 250 total points
ID: 22629671
Then the main proc is where it needs to be created in order for the data to be shared.
0

Featured Post

Backup Solution for AWS

Read about how CloudBerry Backup fully integrates your backups with Amazon S3 and Amazon Glacier to provide military-grade encryption and dramatically cut storage costs on any platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question