SQL Split Data

jollysreek
jollysreek used Ask the Experts™
on
Hello,
I have 3 columns in a table as had data as listed below.

id    col1             col2
1    abc,def        ab,df,gt,ty,yj
2.  as,er,tr,ig      we,re,t,vg,th

If i want to split the data  on both the columns what should i do????


i want the result in the following way,

1    abc     ab
1   def      df
1   Null      gt
1   null      ty and so on.....


Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Billing Engineer
Most Valuable Expert 2014
Top Expert 2009
Commented:
this function dbo.ParmsToList will help:
http://www.experts-exchange.com/A_1536.html

select f1.value, f2.value
  from yourtable t
  cross apply dbo.parmsToList(t.col1) f1
  cross apply dbo.ParmsToList(t.col2) f2

Open in new window


Author

Commented:
can you use a query instead of function for this.... ?
Guy Hengel [angelIII / a3]Billing Engineer
Most Valuable Expert 2014
Top Expert 2009

Commented:
no, not really.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial