Home Forums SQL Server 2005 T-SQL (SS2K5) Temp Table Name confusion with Nested Procedures? RE: Temp Table Name confusion with Nested Procedures?

  • mtillman-921105 (7/1/2011)


    OK, now I wish that I could borrow the head-desk avatar from WayneS! :angry:

    Feel free to borrow it anytime... it's at http://www.dreamwidth.org/userpic/21008/20791

    (Sometimes, I'd like to change my avatar to this one - but I think Steve would ask me to change it.)

    [evil grin]Hmm... isn't Steve on vacation right now?[/evil grin]

    Anyway, to answer your question: From BOL:CREATE TABLE

    A local temporary table created within a stored procedure or trigger can have the same name as a temporary table that was created before the stored procedure or trigger is called. However, if a query references a temporary table and two temporary tables with the same name exist at that time, it is not defined which table the query is resolved against.

    (emphasis mine)

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2