You can use any Numbers table or function to accomplish generating rows. Here is an example using your sample data.This code assumes [Items] will start with one numeric character that can be converted to INT as in your sample data.declare @t table (name varchar(10), items varchar(10))insert @t select 'AAA', '1' union allselect 'BBB', '2,' union allselect 'CCC', '3'select t.name ,'1' + substring(items, 2, 1000) as Itemsfrom @t tjoin master..spt_values n on n.type = 'P' and n.number < convert(int, left(items,1))name Items---------- -----------AAA 1BBB 1,BBB 1,CCC 1CCC 1CCC 1
Be One with the OptimizerTG