Vietnamcode Logo

How to join multi row in sql to string

  • Tuesday, October 16, 2012
  • Unknown
  • Example:
    Consider a database table holding names, with three rows:

    DECLARE @Names VARCHAR(8000) 
    SELECT @Names = COALESCE(@Names + ', ', '') + Name 
    FROM People
    Just some explanation (since this answer seems to get relatively regular views):
    • Coalesce is really just a helpful cheat that accomplishes two things:
    1) No need to initialize @Names with an empty string value.
    2) No need to strip off an extra separator at the end.
    • The solution above will give incorrect results if a row has a NULL Name value (if there is a NULL, the NULL will make @Names NULL after that row, and the next row will start over as an empty string again. Easily fixed with one of two solutions:
    DECLARE @Names VARCHAR(8000) 
    SELECT @Names = COALESCE(@Names + ', ', '') + Name
    FROM People
    DECLARE @Names VARCHAR(8000) 
    SELECT @Names = COALESCE(@Names + ', ', '') + 
        ISNULL(Name, 'N/A')
    FROM People
    Depending on what behavior you want (the first option just filters *NULL*s out, the second option keeps them in the list with a marker message [replace 'N/A' with whatever is appropriate for you]).

    Best Programming Language - Readers' Choice Awards 2011

  • Vietnamcode
  • Best Programming Language


    Runner-up: C++ A three-time winner in our best programming category, Python continues to dominate. Close on its heels this year, however, is C++. In fact, a scant 6% separated the two. It's quite obvious, however, that our readers don't suffer from ophidiophobia in the least—hiss.

    Google driving the Big Data space

  • Vietnamcode
  • Google driving the Big Data space

    Google has unique requirements with respective to data processing and storage which no one has. According to the WikiPedia, Google has to process about 24 Peta Bytes of data per day which be a bit outdated and Google might be processing more data per day. So, they need to continuously innovate to address the unique requirements. Soon they outgrow the innovation and they come up with some new innovation.

    The good thing is that Google had been continuously releasing these innovations  as papers once they have it refined and there is a solid internal implementation of it.

    These Google Papers have been implemented by the ASF (Apache Software Foundation) and others. It's taking some time for the ASF frameworks like Hadoop and others to production ready. There is a catchup between Google papers and the ASF on a continuous basis.

    Google Paper Apache Frameworks

    The Google File System (October, 2003)

    HDFS (2008 became Apache TLP)

    MapReduce: Simplified Data Processing on Large Clusters (December, 2004)

    MapReduce (2008 became Apache TLP)

    Bigtable: A Distributed Storage System for Structured Data (November, 2006)

    HBase (2010 became Apache TLP), Cassandra (2010 became Apache TLP)

    Large-scale graph computing at Google (June, 2009)

    Hama, Giraph (2012 became Apache TLP)

    Dremel: Interactive Analysis of Web-Scale Datasets (2010)

    Apache Drill (Incubated in August, 2012)

    Large-scale Incremental Processing Using Distributed Transactions and Notifications (2010)


    Spanner: Google's Globally-Distributed Database (September, 2012)


    Following the research/papers published by Google and related blogs/articles gives an idea where Big Data is moving. Many might not have the same requirements nor the resources as Google, so we would be seeing more and more cloud services for the same.

    GUI Design Studio

  • Friday, October 12, 2012
  • Vietnamcode
  • GUI Design Studio is a graphical user interface design tool for Microsoft Windows that you can use to rapidly create demonstration prototypes without any coding or scripting. Draw individual screens, windows and components using standard elements, connect them together to storyboard operational workflow then run the simulator to test your designs. GUI Design Studio can be used whenever you need to draw what an application should look like or show how its parts connect and flow together.

    » Create user interface designs quickly and easily
    » Access over 120 built-in design elements
    » Include icons and images in a variety of formats
    » Annotate your design with overlays and side notes
    » Create reusable, modular design components and masters
    » Storyboard your designs to create a dynamic prototype
    » Generate specification documentation
    » Export designs for external review
    » View your design in multiple visual styles
    » Collaborate in teams on your design projects

    Download :