Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert Multiple Records from One Record 1

Status
Not open for further replies.

stephenj789

Technical User
Jan 28, 2002
58
US
Hello, I would like to do the following:

Let's say I have TableA which looks like this:

Identifier Date Days Amount
101 02/07/2007 28 55.55

I would like to insert into a new table 28 records based on the single record above. The Identifier, Days and Amount would stay the same, but the Date would start at 2-7-07 and increment by one for each new record. Then I would like to go to the next record in the source table and do the same. Does anybody have a quick solution? Thanks.
 
Create a table of numbers and use this in a query:

[tt]INSERT INTO tblTable ( Date, Days, Amount )
SELECT [Date]+[NumberX] AS Dte, tblTable.Days, tblTable.Amount
FROM tblTable, Numbers
WHERE Numbers.NumberX<28[/tt]
 
I didn't think I could do it through SQL. Thanks Remou, this helps me a lot!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top