Tuesday, March 20, 2012

Create a comma delimited *field*

Help! (again...)
I have data that looks like this:
date snum
5/9/2007 3064
5/9/2007 3072
5/16/2007 4031
5/16/2007 3856
5/16/2007 4252
(Can recreate with
declare @.temptable table (date smalldatetime, snum int)
insert into @.temptable values('09 May 2007', 3064)
insert into @.temptable values('09 May 2007', 3072)
insert into @.temptable values('16 May 2007', 4031)
insert into @.temptable values('16 May 2007', 3856)
insert into @.temptable values('16 May 2007', 4252)
)
I need to make it look like this:
date snumlist
5/9/2007 3064, 3072
5/16/2007 4031, 3856, 4252
The "snumlist" is being plugged into a javascript function in a
vbscript.asp page. I can easily create the snumlist using while/wend
in vbscript but it seems quite slow! I'm wondering if it wouldn't be
faster to create the comma delimited list in SQL rather than try to
build it with VBScript.
(I can do anything to the temptable that I need to, structure-wise -
it's created on the fly.)
Thanks for any help, a pointer to a web page, a pointer to a previous
post, ANYthing.
Julie
(P.S. This email address forwards to my regular email address. Either
Google or my ISP often marks replies from this newsgroup as spam, so I
never see them. I still haven't gotten it sorted out. If possible,
please reply on list. Thanks, jcls)Sorry - posted this in wrong group. Moving to .programming
Thx, Julie
On May 5, 4:42 pm, Julie <julie.sie...@.gmail.com> wrote:
> Help! (again...)
> I have data that looks like this:
> date snum
> 5/9/2007 3064
> 5/9/2007 3072
> 5/16/2007 4031
> 5/16/2007 3856
> 5/16/2007 4252
> (Can recreate with
> declare @.temptable table (date smalldatetime, snum int)
> insert into @.temptable values('09 May 2007', 3064)
> insert into @.temptable values('09 May 2007', 3072)
> insert into @.temptable values('16 May 2007', 4031)
> insert into @.temptable values('16 May 2007', 3856)
> insert into @.temptable values('16 May 2007', 4252)
> )
> I need to make it look like this:
> date snumlist
> 5/9/2007 3064, 3072
> 5/16/2007 4031, 3856, 4252
> The "snumlist" is being plugged into a javascript function in a
> vbscript.asp page. I can easily create the snumlist using while/wend
> in vbscript but it seems quite slow! I'm wondering if it wouldn't be
> faster to create the comma delimited list in SQL rather than try to
> build it with VBScript.
> (I can do anything to the temptable that I need to, structure-wise -
> it's created on the fly.)
> Thanks for any help, a pointer to a web page, a pointer to a previous
> post, ANYthing.
> Julie
> (P.S. This email address forwards to my regular email address. Either
> Google or my ISP often marks replies from this newsgroup as spam, so I
> never see them. I still haven't gotten it sorted out. If possible,
> please reply on list. Thanks, jcls)|||I'll tell you what they'll tell you over there - what you're trying to do
should be done in the front end. That aside, there are several T-SQL
scripts (some cleverer than others) posted in the .programming newsgroup to
do exactly what you're asking. When you ask over there, be sure to mention
whether or not the ordering of the items in the comma-separated list is
important. From your example it doesn't appear so, but you will probably
want to clarify that.
"Julie" <julie.siebel@.gmail.com> wrote in message
news:1178409829.540816.60210@.p77g2000hsh.googlegroups.com...
> Sorry - posted this in wrong group. Moving to .programming
> Thx, Julie
> On May 5, 4:42 pm, Julie <julie.sie...@.gmail.com> wrote:
>

No comments:

Post a Comment