As part of an redesign, there's need for an different schema in one of the main tables in our database. The data in one of the existing tables will be kept as legacy data.
To make the changeover easier, I'm trying to create a view on the existing data, which can be union'ed with new data, to allow both to be used until the final change.
The scenario is that there's a table which stores the following:
- WorkID
- User
- HoursWorked
- Project
- Number of reports written
It's being modified to become two tables, the first being
- WorkID
- User
- HoursWorked
- Project
- Flag Legacy
And the second, with one row for every report as specified in the number of reports field in the original table.
- ReportID,
- WorkID [fk to first table]
- .. (extra data about the report)
My issue is deriving the second table as a view, that can then be union'ed with data from the new version's table.
So, my question is, how could I go about selecting a row multiple times as specified by a field within that row as a query that can be created as a view - infact is it possible?
The DB is in Sql Server 2008r2
Thanks for your help!