If the values are in one column and several rows, use something like followingdeclare @test table ([option] varchar(2))insert @testselect 'A' union allselect 'B' union allselect 'A' union allselect 'C' union allselect 'D' union allselect 'B'declare @concat varchar(8000)select @concat = isnull(@concat + ',', '') + z.[option]from ( select distinct top 100 percent [option] from @test order by [option] ) zselect @concat as Result
If you have one row and all values are in one column, start withdeclare @test table ([option] varchar(2))insert @testselect distinct paramfrom fnSplit('A,B,A,C,D,B')declare @concat varchar(8000)select @concat = isnull(@concat + ',', '') + z.[option]from ( select top 100 percent [option] from @test order by [option] ) zselect @concat as Result
Peter LarssonHelsingborg, Sweden