Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2011
    Posts
    5

    Unanswered: Equivalent of oracle WM_Concat in sqlserver

    Hi,
    I am trying to get two rows with all columns have same value except one into one row. Can someone tell me how to achieve this in sqlserver 2008?


    Field1 Field2 Field3
    Jane PA DDD
    Tom CA XYZ
    Tom CA ABC

    result should be

    Jane PA DDD
    Tom CA XYZ,ABC

  2. #2
    Join Date
    Mar 2007
    Location
    Holmestrand, Norway
    Posts
    332
    Ole Kristian Velstadbråten Bangås - Virinco - MSSQL.no - Facebook - Twitter

  3. #3
    Join Date
    Aug 2011
    Posts
    5
    If I use the "Concatenating values when the number of items is not known", it is still not a neat way of doing that as it leaves unwanted commas at the end.How do I get rid of commas at the end?

  4. #4
    Join Date
    Mar 2007
    Location
    Holmestrand, Norway
    Posts
    332
    Code:
    substring(<string expression>,1,len(<string expression>)-1)
    Ole Kristian Velstadbråten Bangås - Virinco - MSSQL.no - Facebook - Twitter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •