Select into #t vs. Create @t table + Insert @t select from ...

  • Hi,

    Is there any difference between those 2 way to handle intermediate results, I know that before 2008 it made difference in terms of locks during the whole execution of

    insert into #t from myt

    but I heard that after 2008 it's being takec care of so it doesn't matter you do SELECT INTO #T FROM MYT

    or

    CREATE @T TABLE, INSERT @T SELECT FROM MYT

    Thanks

    Mario

    davai

  • Although it's a bit dated, I still consider the following article to be one of the best on the subject of Temp Tables vs Table Variables.

    http://www.sqlservercentral.com/articles/Temporary+Tables/66720/

    My personal feeling, especially when it comes to ease of troubleshooting, is that I won't use Table Variables anywhere except in functions and that's only because Temp Tables don't work in functions. There will be differing opinions on that but that's my opinion. 😉

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

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

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