Skip to content
Advertisement

Insert rows into same table using data from different rows based on data from another table

I’ve got 2 tables: TimecardSetDetails, TimecardDetails

TimecardSetDetails

TimecardDetails

I need help on inserting each ProjectKey and TaskKey for EmployeeKey = 6023 in the TimecardDetails table (3 rows in this example) into the same TimecardDetails table for each row in the TimecardSetDetails table where SetHistoryID = 10471 but with the new EmployeeKey.

I would like the results to be this:

TimecardDetails

Advertisement

Answer

You can generate the rows with a joinand then insert them into the TimecardDetails table:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement