Jeff Moden (3/20/2013)
Lynn Pettis (3/20/2013)
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?
Yep... I'm thinking the instructor is going to make a mess in his britches when everyone turns in the Tally Table solution. Hopefully, the instructor learns something in the process. 😛
LOL. I guess my "homework meter" has been temporarily disabled. It should be back online in the next few minutes.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/