Loading ...
Sorry, an error occurred while loading the content.

Re: 2 table columns update

Expand Messages
  • Varra Reddy
    I have 2 indetical tables.   1 table:  11 cloumns ( column 1 to column 11) 2 table:  11 columns ( column 1 to column 11)   need update statement on all
    Message 1 of 3 , Jul 22, 2009
    • 0 Attachment
      I have 2 indetical tables.
       
      1 table:  11 cloumns ( column 1 to column 11)
      2 table:  11 columns ( column 1 to column 11)
       
      need update statement on all columns by using ID from table 1 to table 2.
       
       
      Reddy




      [Non-text portions of this message have been removed]
    • mohan mareboina
      Can you be more clear on which rows need to update? However, as per my guess, you would like to have identical tables with data. Use following query Insert
      Message 2 of 3 , Jul 23, 2009
      • 0 Attachment
        Can you be more clear on which rows need to update?

        However, as per my guess, you would like to have identical tables with data. Use following query

        Insert into Table2 (col1, col2, ... col11)
        Select col1, col2, ... col11 from Table1

        Regards,
        Mohan




        ________________________________
        From: Varra Reddy <varra_s@...>
        To: sqlcon@yahoogroups.com
        Sent: Thursday, July 23, 2009 1:13:08 AM
        Subject: MUGH-SQLCON Re: 2 table columns update

         
        I have 2 indetical tables.
         
        1 table:  11 cloumns ( column 1 to column 11)
        2 table:  11 columns ( column 1 to column 11)
         
        need update statement on all columns by using ID from table 1 to table 2.
         
         
        Reddy

        [Non-text portions of this message have been removed]




        [Non-text portions of this message have been removed]
      • Anand Kumar Reddy
        Hi Varra, Updated statement: Update table2 set column1 = table1 .column1,                             column2 = table1 .column2,
        Message 3 of 3 , Jul 24, 2009
        • 0 Attachment
          Hi Varra,

          Updated statement:


          Update table2 set column1 = table1 .column1,
                                      column2 = table1 .column2,
                                      column3 = table1 .column3,
                                       ...............................,
                                       column11 = table1 .column11
          From table2 INNER JOIN  table1
          on table2.id = table1.id

          Regards
          Anand Reddy



          ________________________________
          From: Varra Reddy <varra_s@...>
          To: sqlcon@yahoogroups.com
          Sent: Thursday, July 23, 2009 1:13:08 AM
          Subject: MUGH-SQLCON Re: 2 table columns update

           
          I have 2 indetical tables.
           
          1 table:  11 cloumns ( column 1 to column 11)
          2 table:  11 columns ( column 1 to column 11)
           
          need update statement on all columns by using ID from table 1 to table 2.
           
           
          Reddy

          [Non-text portions of this message have been removed]







          [Non-text portions of this message have been removed]
        Your message has been successfully submitted and would be delivered to recipients shortly.