Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2002

    Question Unanswered: Temp table in store procedure

    Hi everybody
    I am big store procedure which create a temp table during execution and then does select into and insert in this temp table. I am trying to do these steps in another store procedure which is called from the first one. But when I am trying to save second store procedure I am getting the error - "#temp_table is not exists" even thow I run create temp_table statement before save. Any Ideas why I can't save it?

  2. #2
    Join Date
    Mar 2001
    Lexington, KY
    Do this:
    1. Use create table to create the temporary table.
    2. Create the procedures that access the temporary table, but do not create the procedure that creates the table (the 'called' or secondary procedure in your case).
    3. Drop the temporary table.
    4. Create the procedure that creates the table and calls the procedures created in step 2 (the original stored procedure).;pt=19957#X


  3. #3
    Join Date
    Feb 2002
    Usually, temp tables are named with a leading #, like #temp_table. These tables are created in tempdb, and automatically dropped after the stored procedure has done it's job. Give the table a name without leading #, and make sure that you are working in the same database where the table is created, or set a reference to the database like: select * from MyBase..temp_table

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts