Concatenate column values as single value SQL Server 2005 -
i have table column:
|-------------| | columnname | |-------------| | value 1 | | value 2 | | value 3 | | value 4 | | value 5 | |-------------|
i declare variable,
declare @columnnamelist varchar(max)
and should find below value in variable
'value one,value two,value three,value four,value five'
can me out in doing this?
thanks in advance.
select @columnnamelist = stuff ( select ',' + columnname tablename order columnname xml path('root') ), 1, 1, ''
Comments
Post a Comment