Monday, October 1, 2007

[mssql] Listing the Value of Certain Column

Following is the procedure to create a comma separated list of value of certain column.
DECLARE @cList varchar(1000)
SELECT @cList = isnull(@cList + ',', '') + MyColumn
FROM MyTable (NOLOCK)
SELECT @cList --> show result

No comments:

Post a Comment