I'm not sure of the terminology here, so let me give an example. I have this query:
SELECT * FROM Events
--------------------
Id Name StartPeriodId EndPeriodId
1 MyEvent 34 32
In here, the PeriodIds specify how long the event lasts for, think of it as weeks of the year specified in another table if that helps. Notice that the EndPeriodId is not necessarily sequentially after the StartPeriodId. So I could do this:
SELECT * FROM Periods WHERE Id = 34
-----------------------------------
Id StartDate EndDate
34 2009-06-01 2009-08-01
Please do not dwell on this structure, as it's only an example and not how it actually works. What I need to do is come up with this result set:
Id Name PeriodId
1 MyEvent 34
1 MyEvent 33
1 MyEvent 32
In other words, I need to select an event row for each period in which the event exists. I can calculate the Period information (32, 33, 34) easily, but my problem lies in pulling it out in a single query.
This is in SQL Server 2008.