I have some data that looks like this:
Which I need to insert into another table like:
I have a splitstring function, but I am missing something in my brain. What I need to do is
Where colb is a comma-delimited list of values that needs to be broken into separate rows as shown in the data above. Shoot, I can't even explain it well, no wonder I can't get the code down for it. Any thoughts?
wb
Code:
cola colb
3360 182, 183, 739, 188
3361 2807, 2814, 2851, 2827, 1100, 188, 1431
3362 182, 183, 739, 188
3363 674, 1092, 1093, 1102, 1431
3364 182, 2811, 188
3365 182, 183, 739, 188
3366 182, 2811, 2817, 2829, 188, 1431
3367 182, 2812, 2818, 2830, 188, 1431
Which I need to insert into another table like:
Code:
cola colb
3360 182
3360 183
3360 739
3360 188
I have a splitstring function, but I am missing something in my brain. What I need to do is
Code:
insert into tblx(cola,colb,sId,cdate)
select cola,colb,3042, GETDATE() from tbly where colb is not null
Where colb is a comma-delimited list of values that needs to be broken into separate rows as shown in the data above. Shoot, I can't even explain it well, no wonder I can't get the code down for it. Any thoughts?
wb