Get All rows into One String

This is an easy way to get all rows from a SQL table into a string:

select stuff((
                  select ', ' + a_column
                      from [name_of_table]
                      order by table_id
                      for xml path('')
                  ), 1, 1, '')

Tagged with:

Leave a Reply

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

*