Arrays in TSQL ?

  • I can manage passing arrays of values into TSQL for comparison purposes but I was wondering what would be the best way to do multiple inserts ?

    For example,

    I want to pass in several values to be linked to the same values in a M>N relationship. So I want to pass in {1,2,3,4,5,6,7,8,9} and insert multiple rows linking them all to item 1.

    I need to work through the array doing an insert for each value.

    Is this possible without doing multiple calls to a single query accepting one parameter at a time ?

    Thanks in advance

    Steve

    cheers

    dbgeezer

  • One of the most comprehensive articles on that topic can be found here

    http://www.algonet.se/~sommar/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]

  • cool. thanks

    roll on Yukon eh

    cheers

    dbgeezer

  • One more option I can remember is using the charAt function.

    You have to dig for tons of dirt to get an ounce of Gold

  • charAt function in T-SQL ???

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

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

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