Temporary table in a batch

  • Comments posted to this topic are about the item Temporary table in a batch

  • Interesting question

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • Interesting "feature" of SQL Server 🙂

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Nice question.

    Not sure why someone would try to create the same temp table twice in the same procedure. If needing to use the same temp table then clear it and reinsert. Or just use a new temp table with a new name.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Nice question. It's by design.

    Thanks.

    Regards,

    Igor

    Igor Micev,My blog: www.igormicev.com

  • Nice one thanks.

    Hope this helps...

    Ford Fairlane
    Rock and Roll Detective

  • Nice question.

    But the explanation appears to have swallowed the good old party line: sometimes (and it seems reasonably certain that this is one of those times) "it's by design" means "someone made a mess of this, but there's not much point in fixing it so we'll pretend that's what was intended". I've watched that happen in standard writing as well as in code writing and in requirements writing; sometimes the result is pretty harmless, as here, but at other times it is far from harmelss - but the culprits still spout the "it's by design" mantra.

    As for

    explanation


    Books online states it vaguely as

    “If more than one temporary table is created inside a single stored procedure or batch, they must have different names.”

    Detailed explnation is available at - http://www.tectalks.com/493/temporary-table-could-not-be-re-created/

    there is nothing at all vague about the BOL statement, and the "Detailed explanation" doesn't say anything that BOL doesn't.

    Tom

  • Also the Begin is missing after AS at the start 🙂

  • This was removed by the editor as SPAM

  • L' Eomot Inversé (2/9/2014)


    Nice question.

    But the explanation appears to have swallowed the good old party line: sometimes (and it seems reasonably certain that this is one of those times) "it's by design" means "someone made a mess of this, but there's not much point in fixing it so we'll pretend that's what was intended". I've watched that happen in standard writing as well as in code writing and in requirements writing; sometimes the result is pretty harmless, as here, but at other times it is far from harmelss - but the culprits still spout the "it's by design" mantra.

    As for

    explanation


    Books online states it vaguely as

    “If more than one temporary table is created inside a single stored procedure or batch, they must have different names.”

    Detailed explnation is available at - http://www.tectalks.com/493/temporary-table-could-not-be-re-created/

    there is nothing at all vague about the BOL statement, and the "Detailed explanation" doesn't say anything that BOL doesn't.

    + 1, Agree.

    Thanks & Best Regards,
    Hany Helmy
    SQL Server Database Consultant

  • bitbucket-25253 (2/8/2014)


    Interesting question

    + 1, yes.

    Thanks & Best Regards,
    Hany Helmy
    SQL Server Database Consultant

  • Good One.

    ---------------------------------------------------
    "Thare are only 10 types of people in the world:
    Those who understand binary, and those who don't."

  • Good question. I think this is all about SQL being a declarative language.

  • nice question ... thanks for sharing

  • SQLRNNR (2/9/2014)


    Nice question.

    Not sure why someone would try to create the same temp table twice in the same procedure. If needing to use the same temp table then clear it and reinsert. Or just use a new temp table with a new name.

    It`s just not practical to create the same temp table twice in the same SP, there is no logic to do that, but the question was interesting enough that I had to test it my self as never did that before.

    Thanks & Best Regards,
    Hany Helmy
    SQL Server Database Consultant

Viewing 15 posts - 1 through 15 (of 25 total)

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