T-SQL Multi Insert Based on Source Record Value
Posted on 2011-09-13
Hi T-SQL Experts!
I am moving over data to a new database structure and need to insert the same record multiple times based on a particular value in that record. For example, I want to insert rows from a table with the following structure:
OldTable(MyID int, ItemID int, TrackedDate smalldatetime, Counter int)
Into this new structure:
NewTable(NewMyID, ItemID int, TracedDate smalldatetime)
I would like to repeat the INSERT Command for any rows in OldTable by as many times as specified in the Counter field value for that record.
Can anyone provide a clue as to how I can do this using t-sql and not creating a seperate application to do repeated INSERT command? Thanks!