create table tab(id int ,cn int ,OPIS varchar(20))
insert into tab(id,cn,OPIS)
select 1,123,'AAA'
union all
select 2, 000,'eee'
union all
select 3,123,'BBB'
union all
select 4,555,'ccc'
create function fn (@cn int)
returns varchar(max)as
begin
declare @str varchar(200)
select @str = coalesce(@str+',','')+ opis from tab where cn = @cn
return @str
end
select distinct cn ,dbo.fn(cn) as opis from tab
Vijay is here to learn something from you guys.