Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 817729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:02:17+00:00 2026-05-15T02:02:17+00:00

On our production SQL2000 instance, we have a database with hundreds of stored procedures,

  • 0

On our production SQL2000 instance, we have a database with hundreds of stored procedures, many of which use a technique of creating a #TEMP table “early” on in the code and then various inner stored procedures get EXECUTEd by this parent sProc. In SQL2000, the inner or “child” sProc have no problem INSERTing into #TEMP or SELECTing data from #TEMP. In short, I assume they can all refer to this #TEMP because they use the same connection.

In testing with SQL2008, I find 2 manifestations of different behavior. First, at design time, the new “intellisense” feature is complaining in Management Studio EDIT of the child sProc that #TEMP is an “invalid object name”. But worse is that at execution time, the invoked parent sProc fails inside the nested child sProc.

Someone suggested that the solution is to change to ##TEMP which is apparently a global temporary table which can be referenced from different connections.

That seems too drastic a proposal both from the amount of work to chase down all the problem spots as well as possible/probable nasty effects when these sProcs are invoked from web applications (i.e. multiuser issues).

Is this indeed a change in behavior in SQL2005 or SQL2008 regarding #TEMP (local temp tables)? We skipped 2005 but I’d like to learn more precisely why this is occuring before I go off and try to hack out the needed fixes. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T02:02:18+00:00Added an answer on May 15, 2026 at 2:02 am

    sharing a temp table between stored procedures is a nice feature to use: http://www.sommarskog.se/share_data.html#temptables, I’m surprised that it isn’t working for you. Perhaps you should try a very simple example and see if that will work. Then if that works start looking at other reasons.

    try this from a query window in management studio:

    create these two procedures:

    CREATE PROCEDURE called_procedure 
    (@par1 int, @par2 char(5))
    AS
    INSERT INTO  #tmp VALUES (@par1,@par2)
    GO
    
    CREATE PROCEDURE caller
    AS
    
    CREATE TABLE #tmp (col1 int     NOT NULL
                      ,col2 char(5) NULL
                      )
    EXEC called_procedure 1, 'AAA'
    EXEC called_procedure 2, 'BBB'
    
    SELECT * FROM #tmp
    GO
    

    then run them:

    exec caller
    

    This is what I get on SQL Server 2005:

    col1        col2
    ----------- -----
    1           AAA  
    2           BBB  
    
    (2 row(s) affected)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.