Home Forums SQL Server 2008 T-SQL (SS2K8) Add variable number of rows into a table based on the values in another table (without cursors/while loops) RE: Add variable number of rows into a table based on the values in another table (without cursors/while loops)

  • Sean Lange (3/20/2013)


    Sure this isn't too hard using a tally table.

    insert #y

    select #x.DocID, t.N

    from #x

    join tally t on t.N <= #x.pages

    select * from #y

    You can read about a tally table here. http://www.sqlservercentral.com/articles/T-SQL/62867/[/url]

    I'm starting to see a pattern with some of the posts. Looks like people are coming here to get their homework done. Anyone else seeing this?