Home Forums SQL Server 2005 T-SQL (SS2K5) split column into multiple records based on substring fixed lenght RE: split column into multiple records based on substring fixed lenght

  • SELECT x.*

    FROM TableA

    CROSS APPLY (

    SELECT cust, SUBSTRING(wptext, 1, 80), 1 UNION ALL

    SELECT cust, SUBSTRING(wptext, 81, 80), 2 UNION ALL

    SELECT cust, SUBSTRING(wptext, 161, 80), 3 UNION ALL

    SELECT cust, SUBSTRING(wptext, 241, 80), 4 UNION ALL

    SELECT cust, SUBSTRING(wptext, 321, 80), 5

    ) x (cust, wptext, seq)


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]