Insert 5 rows in one table based on a count of records in Another table

  • Hello All:

    I'm trying to set up some re-usable T-SQL for a task that I will likely use repeatedly in the future.

    What I'm trying to do is insert/append five rows(conditions) for each model office in another table.  I have 69 model office rows that I need base my insert off of.  Each of these model offices gets 5 related conditions added to the condition table.  The model office numbers are not consecutive.  So I'm assumning this would make incrementing harder to do. 

    I would also like to fill a model office number field in each of the 5 conditions with the corresponding MO num. 

    Example:

    MO Num: 482

    CondNum   MO Num

       865           482

       866           482

       867           482

       868           482

       869           482

    I'm assuming I should WHILE or BEGIN...END for the loop, but I'm not sure how to accomplish this.  I've come up with a few ideas, but they just don't seem like the cleanest methods.

    Thanks in advance for any help you can provide.  Let me know if you have any questions.

    Thanks,

    Cleech

  • Please do not post in more than one forum.

    http://qa.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=346521

    SQL = Scarcely Qualifies as a Language

  • Sorry About that.  I realized I was in SQL2K5 when I should have been in 2K.  Can I remove this post?

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply