You are here: Re: Combining Values « MsSQL Server « IT news, forums, messages
Re: Combining Values

Posted by imani_technology_spam@yahoo.com on 07/02/07 15:30

Sorry, I'm a little rusty on cursors. How would I pull this off? Can
I (or should I) use nested WHILE loops?

On Jul 2, 3:28 am, Stephen2 <Step...@mailinator.com> wrote:
> On Jul 2, 12:48 am, "imani_technology_s...@yahoo.com"
>
>
>
>
>
> <imani_technology_s...@yahoo.com> wrote:
> > Here's where things get interesting:
>
> > John Doe | Address 1
> > John Doe | Address 2
> > John Doe | Address 3
> > Jane Smith | Address 1
> > Jane Smith | Address 2
>
> > The results need to be
>
> > John Doe | 3; Address 1; Address 2; Address 3
> > Jane Smith | 2; Address 1; Address 2
>
> > I have no idea how to pull this off.
>
> > On Jun 30, 6:39 am, "Marcin A. Guzowski"
>
> > <tu_wstaw_moje_i...@guzowski.info> wrote:
> > > imani_technology_s...@yahoo.com wrote:
> > > > I wish I could, but this is a data migration. I HAVE to put this
> > > > stuff in the table. The customer requires it. More specifically,
> > > > Commerce Server requires it.
>
> > > You have three options:
>
> > > 1) aggregate concatenation in cursor
> > > 2) aggregate concatenation in SELECT query
> > > 3) aggregate concatenation using FOR XML
>
> > > Option 1) is the safest method.
>
> > > For option 2) details refer to:http://groups.google.pl/group/microsoft.public.sqlserver.programming/...
>
> > > Third method:http://sqlblogcasts.com/blogs/tonyrogerson/archive/2006/07/06/871.aspx
>
> > > --
> > > Best regards,
> > > Marcin Guzowskihttp://guzowski.info-Hide quoted text -
>
> > - Show quoted text -
>
> You could use a WHILE loop to select row by row for each person.
> SELECT the COUNT of addresses for the current person into one variable
> and build up a text string of the concatenated addresses into another
> variable looping round until you've got them all. Then update the
> column in the table with the value of the variables.- Hide quoted text -
>
> - Show quoted text -

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация