1 Reply Latest reply on Apr 30, 2007 7:23 AM by paross1

    stored procedure help - ms sql server

      [1] basically I need to select certain rows from the db and grab their IDs... ( done)
      [2] now I have to perform a series of insert statments based on those ids retrieved.

      I thought about storing the results of [1] into a table variable and then looping over that variable to perform my insert statments...

      how can this be done?
        • 1. stored procedure help - ms sql server
          paross1 Level 2
          Your insert doesn't specify which previously selected values match up with which columns in the insert table time_trk_history so it is hard to recommend more than a hypothecical. Having said that, why don't you move your SELECT statment into your INSERT statement:

          INSERT INTO
          (caseID, dateCreated, status_to_colorID, dateTimeStart, commentID)
          SELECT hist.id, @timeoutDays_Green, and whatever other columns and constants that you want
          FROM time_trk_history hist, time_trk_items items
          WHERE whatever.....