Array

  • How can I create an array to hold the results of a select query? Basically, I have a stored procedure that uses the results of a sub-query within a recordset. At the moment, as the procedure loops through each item within the recordset it runs a select a statement to retrieve a list of values that will be used for comparison purposes. Instead of continually querying the table I would like to query it once and hold the results in an array.

    Thanks

  • http://www.sommarskog.se/arrays-in-sql.html

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Thanks Frank

  • How about multi dimensional arrays?

     

    Or an array of say 24 records always... so 24 entries but then the values change over time.. there are other processing.

  • Hi,

    Unfortunately, the number of elements within the array will be different each time so it needs to be dynamic.

  • Erland Sommarskog also wrote one of the most referenced article regarding dynamic sql. You'll find the article also on the his homepage. If that doesn't help you, please post the code you've so far. along with DDL and desired output.

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

Viewing 6 posts - 1 through 5 (of 5 total)

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