• Jaat (5/2/2012)


    I´m sorry i did not know the rules to answer something, but based on best practices we should avoid making string operations on the database side for performance that´s my understanding, beside i add some code

    IF OBJECT_ID('#Tbl_TempTable') IS NULL

    BEGIN

    CREATE TABLE #Tbl_TempTable

    (

    ID INT IDENTITY

    ,FName VARCHAR(30)

    ,EnterDtm DATETIME DEFAULT GETDATE()

    )

    END

    DECLARE @XML XML

    SET @XML =

    '<Root>

    <PrimerNombre>Juan Valdez Calambuco</PrimerNombre>

    <PrimerNombre>Juan Primero</PrimerNombre>

    <PrimerNombre>Juan Segundo</PrimerNombre>

    <PrimerNombre>Juan Tercero</PrimerNombre>

    <PrimerNombre>Juan Cuarto</PrimerNombre>

    <PrimerNombre>Juan Quinto</PrimerNombre>

    <PrimerNombre>Juan Sexto</PrimerNombre>

    <PrimerNombre>Juan Septimo</PrimerNombre>

    <PrimerNombre>Juan Octavo</PrimerNombre>

    </Root>

    '

    INSERT INTO #Tbl_TempTable (FName)

    SELECT T.c.value('.','VARCHAR(30)') from @XML.nodes('//Root/PrimerNombre') T(c)

    SELECT * FROM #Tbl_TempTable

    let me know if it works, if not i will try to provide a better solutions thanks

    That would be helpful but unfortunately it is not what the OP is trying to solve. They have a comma separated list and want to parse that into individual rows.

    Not sure if you noticed but this thread is 3 years old and the OP has not logged in for about a 1 1/2 years. 🙂

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/