Developping for the translation industry RSS 2.0



 Monday, 11 July 2011

Sometimes we need to create a CSV list of items, containing in a single row the different values of a column in a table.

This script just accomplish that, in the simplest manner possible:

DECLARE @theListOfValues VARCHAR(MAX)
SELECT @theListOfValues = COALESCE(@theListOfValues+',' , '') +
MyColumn
FROM 
MyTable
SELECT @theListOfValues

 

Other posts:

How to remove multiple whitespaces from a string with SQL Server 2005

Which performs better: ISNULL or COALESCE

How to remove leading zeros from the results of an SQL Query

Simple way to count characters and words using T-SQL

Domain registration and one full year of Web hosting for Free!

Monday, 11 July 2011 10:19:50 (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
SQL

Navigation
Advertisement
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2018
Stanislas Biron
Sign In
Statistics
Total Posts: 135
This Year: 0
This Month: 0
This Week: 0
Comments: 1
All Content © 2018, Stanislas Biron