I have a table called Employees:
BeginYear | EndYear | Name
1974 1983 Robert
For each record in Employees I need to insert each year into a new table called EmployeeYears
So:
For Each Record in Employees
For i as int = Begin Year to End year
INSERT i, Name into EmployeeYears
Any Way to do this in SQL…possibly with cursors?
The gist of it is using a WITH statement to create all the records and use them to insert into your final table.
Testdata
Results