• Using the splitter here http://www.sqlservercentral.com/articles/Tally+Table/72993/

    SELECT t.CONTINENTID,

    s1.Item AS COUNTRY,

    s3.Item AS CITY

    FROM @T t

    CROSS APPLY dbo.DelimitedSplit8K(t.COUNTRIES,',') s1

    CROSS APPLY dbo.DelimitedSplit8K(t.CITIES,'|') s2

    CROSS APPLY dbo.DelimitedSplit8K(s2.Item,',') s3

    WHERE s1.ItemNumber = s2.ItemNumber

    ORDER BY t.CONTINENTID,s1.ItemNumber,s3.ItemNumber;

    ____________________________________________________

    Deja View - The strange feeling that somewhere, sometime you've optimised this query before

    How to get the best help on a forum

    http://www.sqlservercentral.com/articles/Best+Practices/61537