I didn't read the article so for all I know I'm offering up the same solution but I doubt it. Anyways, the concept behind this is called walking the tree, or so I've heard it called. It's not particularly elegant but it works.The first thing you need is a table that contains a series of numbers starting at 1 up to however many you need. A simple table like the following will do:create table walkers(zombie int);insert into walkers values (1),(2),(3)..... There are all kinds of ways to populate the table so I'll skip that and it's probably easier to call it id rather than zombie but you get the obvious tie-in to the Walking Dead.Here's the code:DECLARE @var char(30);DECLARE @var1 char(30);SET @var = '12345678 SCINC, SCNRQ, SRPPR';SET @var1 = REPLACE(REPLACE(@var,SUBSTRING(@var,1,CHARINDEX(' ',@var)),''),', ','.')-- This does two things. First it removes the order_id from the string and then it converts the comma and space to a period so the function works with PARSENAME (man, used that twice in one day).SELECT SUBSTRING(@var,1,CHARINDEX(' ',@var)) AS Order_ID,PARSENAME(@var1,zombie) AS SKUFROM walkersWHERE LEN(@var) - LEN(REPLACE(@var,' ','')) >= zombie
If you have more than one record, and obviously you will, you need to join the walkers table to your table. I didn't do that here but any kind of join that limits the counter to the number of sku's will work. A full outer join with a WHERE clause or a non equi join will also work.Order_ID SKU12345678 SRPPR 12345678 SCNRQ12345678 SCINC