insert duplicate row in a table

  • Hi,

    I want to insert a duplicate row in a table. I want to insert a new row in a table that should have the same values as of the previous row and in addition to that, i will be changing 2 or 3 colums values from the previous row to the new row. For example.., i have the following columns in a table ID (primary key),orderid , jobid, added_by, comments, serialno, created_date, modified_date. I want to insert a new row that has the same values of orderid , jobid, added_by, comments, created_date, modified_date and in addition i will only change the serialno column, by getting the max(serialno) for the given orderid and jobid and increment it by 1 and then insert that into the new row. Can you tell me how it could be done?

    Thanks,

    Raja

  • Write a SELECT to get the row you want, changing the values if you need to.

    For example, to change the date forward for a date in an order table

    select dateadd( d, 2, orderdate) 'orderdate'

    from orders

    Then put an INSERT in front of it.

    happy to help, want to see you try.

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

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