• Instead of creating a special function for the purpose, I just went with Jeff Moden's community DelimitedSplit8K (http://www.sqlservercentral.com/articles/Tally+Table/72993/) to get this:

    DECLARE @T TABLE

    (DETAILS_ID VARCHAR(100), DETAILS VARCHAR(100))

    INSERT INTO @T

    SELECT 'EA22749B180C41D09B4CC986D21C8F02','2006-11-28|1900-01-01|1||PL625245|'

    ;WITH MySplit AS (

    SELECT DETAILS_ID, DETAILS, ItemNumber

    ,Item=CASE WHEN ItemNumber <= 2 THEN CONVERT(VARCHAR(10), CAST(Item AS DATE), 101) ELSE Item END

    FROM @T

    CROSS APPLY DelimitedSplit8K(DETAILS, '|'))

    SELECT DETAILS_ID

    ,Col1=MAX(CASE WHEN ItemNumber = 1 THEN Item END)

    ,Col2=MAX(CASE WHEN ItemNumber = 2 THEN Item END)

    ,Col3=MAX(CASE WHEN ItemNumber = 3 THEN Item END)

    ,Col4=MAX(CASE WHEN ItemNumber = 5 THEN Item END)

    FROM MySplit a

    GROUP BY DETAILS_ID

    Edit: Initially I didn't notice you wanted the data in 4 columns so I corrected to a crosstab query.


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St