September 20, 2011 at 7:07 am
We need help to burst a single record into multiple copies of that source record
The number of copy is based on a field value of the source record.
Scenario:
a course has 10 students of a stated Teacher, I need to burst that course record into 10 copies in a query.
The query output is then feed to Finance staff for their process and analysis.
We want to do this in SQL Server 2005 in order to automate the bursting. We prefer control the output to avoid problem in the User Community.
The source record is in a single table, no join, no duplication.
September 20, 2011 at 7:24 am
that "burst" keyword your using is throwing me off...i'm not sure what you mean.
you can use a "Tally" or "Numbers" table (search here on SSC) to cross join as many rows as you want:
SELECT TeacherRecs.*
from TeacherRecs
CROSS JOIN (SELECT row_number() OVER(ORDER BY t1.name) As N
from sys.columns t1 cross join sys.columns t2) Tally
WHERE Tally.N <= TeacherRecs.StudentCount
Lowell
September 20, 2011 at 10:14 am
Thank you, your suggestion works.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply