Dataset

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • OuTCasT
    Contributor
    • Jan 2008
    • 374

    Dataset

    I would like to know if its possible to select data from 2 or more tables with an inner join into one dataTable ???
    then update that information and save them back to the tables.
    ?
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Yes.

    Code:
    select key1, table1.col1, table2.col2, space(5) as newcol
    into newtable
    from table1
    inner join table2 on table1.key1 = table2.key1
    
    update newtable
    set newcol = newvalue
    where condition = true
    
    update table1
    set somecolumn = newcol
    from newtable
    inner join table1.key1 = newtable.key1
    
    drop table newtable
    you may also use temporary table, so just place a "#" on the newtable name.

    -- CK

    Comment

    Working...