temp table scope

  • I'm having trouble understanding the scope and availability of temporary tables to my stored procedures.

    What I want to do is place items and shipping locations into two temporary tables using stored procedures.

    Then I want to use a stored procedure to take all the order information plus the item and shipping information from my temp tables and insert a complete order.

    Whenever I test my results from the first SP that inserts the item info I get "Invalid object name" (from Query Analyzer). If I just do straight "CREATE TABLE" code from QA it works fine.

    Are Temp tables created in stored procedures available to other stored procedures?

  • Not if defined as #tempTbl this is local only and only available in 1 procedure as once the procedure ends the table is cleanedup, must be ##tempTbl which makes them Global and any connection or process can access them, however you will need to clean up to make sure is done properly or it will hold until all connections touching the table have disconnected and you can potiential step on yourself if not carefull.

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply