Home Forums SQL Server 7,2000 T-SQL T-SQL Challenge, One row to Many based on Quantity RE: T-SQL Challenge, One row to Many based on Quantity

  • Output would be something like:

    Item 1, Widget, 2

    Item 1, Widget, 2

    Item 2, Junk, 17

    Item 2, Junk, 17

    Item 2, Junk, 17

    Item 2, Junk, 17

    Item 2, Junk, 17

    Item 2, Junk, 17

    Item 2, Junk, 17

    Item 2, Junk, 17

    Item 2, Junk, 17

    Item 2, Junk, 17

    Item 2, Junk, 17

    Item 2, Junk, 17

    Item 2, Junk, 17

    Item 2, Junk, 17

    Item 2, Junk, 17

    Item 2, Junk, 17

    Item 2, Junk, 17

    Item 3, Bars, 9

    Item 3, Bars, 9

    Item 3, Bars, 9

    Item 3, Bars, 9

    Item 3, Bars, 9

    Item 3, Bars, 9

    Item 3, Bars, 9

    Item 3, Bars, 9

    Item 3, Bars, 9

    We know we could use a temp or existing table with 10000+ rows in it by doing something like this.

    select * from items i inner join numbers n

    on i.quantity <= n.number

    I'm happy with this result and doing it this way. ANother guy in my office has some kind of weird obsession with not doing it this way and wants use temp tables specifically created with the rows needed.

    I know in 2005 this is easily done with a CTE or ROW_Number and cross applies but I want to show him a sql 2000 solution.

    Consider it a challenge.