How to write optimized query for this case

  • Suppose I have table CityInfo as -

    Package IDCity

    ----------------------

    2 Pune

    2 solapur

    2 Nashik

    3 Satara

    3 Kolhapur

    4 Mumbai

    4 Nagpur

    I want result table in format ….

    Package IDCity

    --------------------------

    2 Pune,Solapur,Nashik

    3 Satara,Kolhapur

    4 Mumbai,Nagpur

    What is the Optimized query that you can think of??

  • Try a google search for String concatenation XML Path.

    Should get you several references.

    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
  • Great !!! It worked for me.

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

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