Re: Getting comma separated values in a column
msnews.microsoft.com
Date: 09/08/04
- Next message: Ian: "VB Date formating Update problem"
- Previous message: Nick Dakoronias: "Re: Ms SQL server db options for performance issues after db corruption"
- Maybe in reply to: msnews.microsoft.com: "Re: Getting comma separated values in a column"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 8 Sep 2004 07:43:46 -0400
Thanks for the replies, everyone.
All the solutions sem to work fine, however, I can't seem to impliment them
into what I need to do. The following is a layout of what my table
currently looks like (tab separated)....
custno additcustnos orderid
123 874,521,625 15
541 53
852 846 12
>From that, what I need to do is produce a temp table that would look like
this....
custno orderid
123 15
874 15
521 15
625 15
541 53
852 12
846 12
It would also be nice to know how many additcustnos where is the column.
Anyways, I really appreciate all the help. Thanks a lot.
Ja
"Anith Sen" <anith@bizdatasolutions.com> wrote in message
news:uWBitbrjEHA.3148@TK2MSFTNGP10.phx.gbl...
> Here is another approach:
>
> DECLARE @v VARCHAR(100)
> SET @v = '123,abc,rew,blah,uuu45678,h,3342'
> SELECT SUBSTRING( @v, n, CHARINDEX( ',', @v + ',', n ) - n )
> FROM ( SELECT COUNT( * )
> FROM sysobjects s1, sysobjects s2
> WHERE s2.id <= s1.id
> GROUP BY s1.id ) Nbrs ( n )
> WHERE SUBSTRING( ',' + @v, n, 1 ) = ',' ;
>
> Replace the derived table with a table of numbers & you will get a generic
> solution.
>
> --
> Anith
>
>
- Next message: Ian: "VB Date formating Update problem"
- Previous message: Nick Dakoronias: "Re: Ms SQL server db options for performance issues after db corruption"
- Maybe in reply to: msnews.microsoft.com: "Re: Getting comma separated values in a column"
- Messages sorted by: [ date ] [ thread ]