InlineAggr
This function help to have a simply string concatenation.
example:
select c1,[dbo].[InlineAggr](c2,';',0,0),[dbo].[InlineAggr](c3,';',1,-1)
from
(
select 'a1'c1,'b1'c2,'c1'c3 union all
select 'a1'c1,'bfd1'c2,'cwe1'c3 union all
select 'a1'c1,'bas1'c2,'cfffff1'c3 union all
select 'a1'c1,'bas1'c2,'cfffff1'c3 union all
select 'a2'c1,'b2'c2,'c2'c3 union all
select 'a3'c1,'b3'c2,'c3'c3 union all
select 'a4'c1,'b4'c2,'c4'c3 union all
select 'a5'c1,'b5'c2,'c5'c3 union all
select 'a6'c1,'b6'c2,'c6'c3
)t
group by c1
parameters:
@value:
it's the column to concatenate
@del:
it's the delimitator of values
@distinct:
if you need to keep only one distinct values.
could be 0 (all) or 1 (distinct)
@sort:
0 if don t need to sort values, 1 to sort by asc and -1 for desc order