Welcome Guest Search | Active Topics | Members | Log In | Register

string custom aggregate function Options · View
matanel@hotmail.com
Posted: Saturday, October 20, 2007 10:18:28 PM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 20/10/2007 22:18:28
Date: Sun, 21 Oct 2007 05:18:28 -0700

I need to implement a new aggregate function to aggregate strings,
how can I do it in mssql??
More details:
I have a table with 2 columns fk and name like this:
fk| name

1 | a
2 | b
1 | c
1 | d
2 | e
2 | f
3 | g

and after use something like this:
select fk,custom_aggregate_func(name) as result from table group by fk
the result will be:
fk | result

1 |a,c,d
2 |b,e,f
3 |g

Does anyone knows a technique for implementing this in mssql??
I know that in oracle 10g there is function called collect for this
feature, is there anything like that for mssql??
thanks

Sylvain Lafontaine
Posted: Sunday, October 21, 2007 8:06:07 AM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 21/10/2007 08:06:07
Date: Sun, 21 Oct 2007 12:06:07 -0400

See the following post from Anith Sen:

http://groups.google.com/group/microsoft.public.sqlserver.programming/msg/2d85bf366dd9e73e
And the following article:http://www.projectdmx.com/tsql/rowconcatenate.aspx

--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: sylvain aei ca (fill the blanks, no spam please)



<matanel@hotmail.com> wrote in message
news:1192969108.895511.260070@i13g2000prf.googlegroups.com...
>I need to implement a new aggregate function to aggregate strings,
> how can I do it in mssql??
> More details:
> I have a table with 2 columns fk and name like this:
> fk| name
> --------------
> 1 | a
> 2 | b
> 1 | c
> 1 | d
> 2 | e
> 2 | f
> 3 | g
>
> and after use something like this:
> select fk,custom_aggregate_func(name) as result from table group by fk
> the result will be:
> fk | result
> -------------
> 1 |a,c,d
> 2 |b,e,f
> 3 |g
>
> Does anyone knows a technique for implementing this in mssql??
> I know that in oracle 10g there is function called collect for this
> feature, is there anything like that for mssql??
> thanks
>


Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFPro Theme Created by Jaben Cargman (Tiny Gecko)
Powered by Yet Another Forum.net version 1.9.1.1 (NET v2.0) - 9/10/2007
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.
This page was generated in 0.055 seconds.