Looking for the best way to create a comma-delimited values string for each record sin resultset without a cursor.

  • If someone can give me a hand on how to most efficiently modify the attached SQL without a cursor (to turn multiple rows in a column into 1 concatenated comma-delimited string, I appreciate.

    Thank you.

    Likes to play Chess

  • I like to use the FOR XML PATH method. It's detailed here: https://www.simple-talk.com/sql/t-sql-programming/concatenating-row-values-in-transact-sql/

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • VoldemarG (3/24/2016)


    If someone can give me a hand on how to most efficiently modify the attached SQL without a cursor (to turn multiple rows in a column into 1 concatenated comma-delimited string, I appreciate.

    Thank you.

    Quick question, why would you like to do this? A denormalization like this isn't useful but for reporting/presentation purposes, much better to store the objects' id in a separate one to many table, easy to generate the comma separated list of names from there when needed.

    😎

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

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