Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Split column values

Author  Topic 

infodemers
Posting Yak Master

183 Posts

Posted - 2011-02-25 : 13:33:21
Hi from a result like this
Num Code Start Date End Date
204-201 ABCDF 2004-04-04 NULL
204-203 ABCDF 2004-07-18 NULL
204-205 QWERT,ASDFG 2005-12-05 NULL
204-206 YUIOP,GHJKL 2006-05-11 NULL

I wish to get this :
Num Code Start Date End Date
204-201 ABCDF 2004-04-04 NULL
204-203 ABCDF 2004-07-18 NULL
204-205 QWERT 2005-12-05 NULL
204-205 ASDFG 2005-12-05 NULL
204-206 YUIOP 2006-05-11 NULL
204-206 GHJKL 2006-05-11 NULL

The column that sometimes has coma seperated values are then split to creat another record with same Num, Start Date and End Date.

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-02-25 : 13:42:32
This might help: http://www.sqlteam.com/article/parsing-csv-values-into-multiple-rows
Go to Top of Page

infodemers
Posting Yak Master

183 Posts

Posted - 2011-02-25 : 17:05:21
Thanks a lot robvolk!

It worked just like I wished!
Go to Top of Page
   

- Advertisement -