Spilt string into seperate fields

  • I would write something easier to maintain like:

    SELECT  Account

      , IDENTITY(int, 0,1) as AddrNbr

      , substring(';'+ Address ,n + 1,

        Charindex(';',';'+ Address , n + 1 )- n -1 )as Addr

    INTO #Addresses

    FROM

    ( SELECT n,Account,Address

      From Numbers CROSS JOIN dbo.AddrSrc

      Where n <= 50

    &nbsp Nbr

    Where substring(';'+ Address, n, 1)= ';' and n <= Len(';'+ Address )-1

    Order by Account , n

    SELECT Account, AddrNbr % 5 +1 AS AddrNo, Addr  FROM #ADDRESSES order by 1,2

    Drop Table #ADDRESSES

    Then Change the limiting numbers accordingly

    Just my $0.02


    * Noel

  • Sounds fair. If was just and interesting idea. Ofcourse with Yukon this sort of thing will be easy with c# using split.

     

Viewing 2 posts - 16 through 16 (of 16 total)

You must be logged in to reply to this topic. Login to reply