Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2009

    Red face Unanswered: copy, and insert row

    What I want to do is:

    first: copy one record from a table with certain creteria
    second: just update two fields (these two fields are part of the key)
    third: insert this new record into the same table

    This talbe has more than 100 fields. (yeah, I know it sounds ridiculous that the table has more than 100 fields, but this is a very complicated system and that's how the thing works here.)

    can somebody please show me how to write the query? If you could provide me with a sample example, that will be great!

  2. #2
    Join Date
    Apr 2002
    Toronto, Canada
      INTO daTable
    SELECT column1
         , column2
         , ...
         , 'newvalue' AS columnM
         , 937 AS columnN
         , ...
         , column100
      FROM daTable
     WHERE columnM = 'oldvalue'
       AND columnN = 21 | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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