February 21, 2017 at 3:08 am
For Town column I have split the single column into multiple columns if there is any comma values.
City | Town |
Rajasthan | Alwar,Laipur,Ajmer,Kota |
Haryana | Hisar,Jhajjar,Rohtak |
Maharastra | Mumbai,Pune, |
Output:
City | Town1 | Town2 | Town3 | Town4 |
Rajasthan | Alwar | Laipur | Ajmer | Kota |
Haryana | Hisar | Jhajjar | Rohtak | |
Maharastra | Mumbai | Pune |
Saravanan
February 21, 2017 at 7:41 am
You probably need to do this in 2 steps.
First you need to split the values as shown here: http://www.sqlservercentral.com/articles/Tally+Table/72993/
Then you would need to transpose the rows and convert them into columns as shown in the following articles:
http://www.sqlservercentral.com/articles/T-SQL/63681/
http://www.sqlservercentral.com/articles/Crosstab/65048/
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply