array variables in sql server?

  • Hi what are my options for implementing and using array variables in SQL Server? The app I'm currently working on uses SQL Server 2008 so the array implementation needs to be compatible with SS2008. Out of curiosity, has SS array support improved in any way since 2008?

  • Nope, but you can always make a temp table with an identity column 😀

  • Out of curiosity, has SS array support improved in any way since 2008?

    Yep, in 2012 they included CHOOSE.

    I never see it used though....

    Hmmmm, now I'm curious to how it compares to a temp table variable... something I might play around with:rolleyes:

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • I vote for either temp table or table variable.



    Alvin Ramard
    Memphis PASS Chapter[/url]

    All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.

    For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • sqlguy-736318 (7/22/2015)


    Hi what are my options for implementing and using array variables in SQL Server? The app I'm currently working on uses SQL Server 2008 so the array implementation needs to be compatible with SS2008. Out of curiosity, has SS array support improved in any way since 2008?

    What kind of array are you interested in emulating?

    --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)

  • Alvin Ramard (7/22/2015)


    I vote for either temp table or table variable.

    Yep.

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • But a temp table / table variable won't begin to match the performance of a true array.

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • ScottPletcher (7/23/2015)


    But a temp table / table variable won't begin to match the performance of a true array.

    C'est la vie.



    Alvin Ramard
    Memphis PASS Chapter[/url]

    All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.

    For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]

Viewing 8 posts - 1 through 7 (of 7 total)

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