Re: Combine Multiple Records
From: Ilya Margolin (ilya_no_spam__at_unapen.com)
Date: 08/11/04
- Next message: Darren Green: "Re: Transform data to a new file every time"
- Previous message: Lee: "Re: Error Loading DTS Package"
- In reply to: Ilya Margolin: "Re: Combine Multiple Records"
- Messages sorted by: [ date ] [ thread ]
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
> >
> >
>
>
- Next message: Darren Green: "Re: Transform data to a new file every time"
- Previous message: Lee: "Re: Error Loading DTS Package"
- In reply to: Ilya Margolin: "Re: Combine Multiple Records"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|