Re: Combine Multiple Records

From: Ilya Margolin (ilya_no_spam__at_unapen.com)
Date: 08/11/04


Date: Wed, 11 Aug 2004 09:42:34 -0400


...make sure the Comment column has enough space in it.

Ilya

"Ilya Margolin" <ilya_no_spam_@unapen.com> wrote in message
news:%23bPfDitfEHA.2764@TK2MSFTNGP11.phx.gbl...
> Mike,
>
> You would have to do it in a loop or in a cursor. Here is a loop example:
>
> Declare @MaxSeg smallint
> ,@Counter smallint
>
> Select @MaxSeg = Max([Seq#]) From <Comments table>
>
> Set @Counter = 1
>
> While @Counter <= @MaxSeg Begin
>
> Set @Counter = @Counter + 1
>
> Update c1
> Set Comment = Comment + c2.Comment
> From <Comments table> c1
> Inner Join <Comments table> c2
> On c1.[Comment#] = c2.[Comment#]
> Where c1.[Seq#] = 1
> And c2.[Seq#] = @Counter
>
> Delete <Comments table>
> Where [Seq#] = @Counter
> End
>
> The example will stock all comments into Seq# = 1 rows and get rid of the
> rest of Seq#. The code was not tested.
>
> Ilya
>
> "Mike" <mbaith@yahoo.com> wrote in message
> news:ekOCiymfEHA.596@TK2MSFTNGP11.phx.gbl...
> > I have a table that has comments in it, but the way they are formatted
> isn't
> > very easy to work with. For Example:
> >
> > Comment# Seq# Comment
> > 12345 1 Please ship this
> > 12345 2 order today.
> >
> > What is shown is comment # 12345, which has 2 records (They can have
many)
> > to make the comment "Please ship this order today"
> >
> > I would like to use a DTS job to transform this comment into one record
> and
> > eliminate the seq #. The above would become:
> >
> > Comment# Comment
> > 12345 Please ship this order today.
> >
> > Does anyone know how to accomplish this?
> >
> > Thanks,
> > Mike
> >
> >
>
>



Relevant Pages

  • RE: Mid and Find in macro
    ... "Mike H" wrote: ... I want to remove the first word. ... Loop Until Selection = "" ... Your in an endless loop hold down the CTRL key and tao BREAK/Pause and then ...
    (microsoft.public.excel.programming)
  • Re: Dry and dropper question
    ... Mike> Tie your dropper on, and mount your dry fly using a loop. ... If you want to adjust ...
    (rec.outdoors.fishing.fly)
  • Re: A first--- stolen pins from tow bar
    ... >We are planning to spend a week or so at Fort Wilderness in Feb. ... >Loop 300 looked good on the map. ... If you were to stay in the loop near the Settlement you could easily ...
    (rec.outdoors.rv-travel)
  • RE: Mid and Find in macro
    ... "Mike H" wrote: ... I want to remove the first word. ... Loop Until Selection = "" ... Your in an endless loop hold down the CTRL key and tao BREAK/Pause and then ...
    (microsoft.public.excel.programming)
  • Re: Fast way to read string one char at a time
    ... I totally agree with Mike and Jon! ... > The foreach loop will be slower in the case that you provide as it has a ... The foreach loop ... > goes wrong it can free up the Enumerator interface if it implements the ...
    (microsoft.public.dotnet.framework.performance)