Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2010
    Location
    Hyderabad
    Posts
    12

    Unanswered: Inserting multiple records

    Hi,

    presently i am working on designing Timetable builder, i completed designing and updating. I did timetable for one week every week it changes and some times it may be same as last week.

    Now the point is "Same as previous week" button, when i click on this button i need to
    1) update old five to be disabled (last week date records status=0)
    2) inserting these old five records with new week dates (status=1)

    I want to do these two operation at same time in stored procedure.

    Please help me on this how to work.

  2. #2
    Join Date
    Dec 2007
    Location
    London, UK
    Posts
    741
    It would have helped to know the keys and other columns involved and what version of SQL Server you are using but here's an example that may help you.

    Code:
    INSERT INTO TimeTable (weeknum, status, col1, col2)
    SELECT 2 weeknum, 1 status, col1, col2
    FROM
    (
      UPDATE TimeTable SET status = 0
      OUTPUT deleted.*
      WHERE weeknum = 1
    ) t;
    I'm not so sure about the design you are implying here. That you are inserting the same data each week suggests there might be some redundancy in the data.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •