Home Forums SQL Server 2005 T-SQL (SS2K5) How to multiply rows in one table based on the value on another table RE: How to multiply rows in one table based on the value on another table

  • Here's another possibility:

    declare @t1 table (Id int)

    insert into @t1 (Id)

    select 1 union

    select 2 union

    select 3

    declare @t2 table (Id int, X int)

    insert into @t2 (Id, X)

    select 1, 10 union

    select 2, 5 union

    select 3, 0;

    with t3 as (

    select id, x, row_number() over (partition by id order by id) ro from @t2

    cross join sys.all_columns

    )

    select id, x from t3 where ro <= x

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.