• Paarthasarathy (7/20/2010)


    Hi,

    I have a need to split a varchar column into multiple columns based on a delimiter.

    Hi have a variable named @a varchar(max)

    it contains value similar to below

    select @a = '1,a,b,20080101|2,c,d,20080102|3,e,f,20080102'

    like i need to insert it into a table

    with columns( a1 int, a2 char, a3 char, a4 datetime)

    Is it worth writing a function with user defined table valued parameter or any other thoughts?

    I would be happy to receive codes for accomplishing this?

    Please see the following "how to" article for a T-SQL only solution...

    http://www.sqlservercentral.com/articles/T-SQL/63003/

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)