• I am pretty sure that Jeff was thinking of using the DelimitedSplit8K function for this.

    I create the ddl and sample data for you to demonstrate how you should post this in the future.

    create table #Something

    (

    CityRank int,

    Country varchar(10),

    City varchar(200)

    )

    insert #Something

    select 1, 'india', 'hyderabad, bangalore, delhi, shimla' union all

    select 2, 'usa', 'newjersey, newyork, washington, texas' union all

    select 3, 'uk', 'london, greenland, denmark, italy, spain'

    select CityRank, Country, ltrim(x.Item)

    from #Something s

    cross apply dbo.DelimitedSplit8K(s.City, ',') x

    drop table #Something

    You will need to read the article in my signature about splitting strings. In there you will find how to make the DelimitedSplit8K function on your server. Make sure you read and understand the technique here.

    _______________________________________________________________

    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/