Home Forums SQL Server 2008 SQL Server 2008 - General how to split the comma delimited string into rows without using LOOP, CTE, XML. RE: how to split the comma delimited string into rows without using LOOP, CTE, XML.

  • Jeff Moden (10/11/2013)


    mynkdby (10/9/2013)


    DECLARE @PARAMETER NVARCHAR(MAX)

    SELECT @P = 'MONDAY,SUN,FUN,D'

    In order to help with this, you need to answer a serious question. Why must it be without a loop or CTE?

    Jeff i am just exploring things to learn more, not any specific reason behind that we cant use loop,xml and CTE.

    and i came across with the solution like this.. i am replacing the comma with ’ UNION ALL SELECT ‘ (Single Quote & “UNION ALL SELECT” & Single Quote) and that works.

    Thanks jeff making me aware of the fact that code like that are VERY prone to SQL Injection. I would appreciate it if you could enlighten me on this more.

    Thanks in Advance