SELECT column values into a concatenated string (SQL)

Often there is a requirement to get column values in a table to a concatenated string. Say, we have e-mail ID as one column on a person table and want a comma separated list of all (or a subset) of e-mail ID’s.

Here is one dirty little piece of code to do just that! :)

The above query returns a concatenated string of values in EmailID column, separated by semi-colon.

3 thoughts on “SELECT column values into a concatenated string (SQL)

Leave a Reply

Your email address will not be published. Required fields are marked *