• geervani (9/24/2009)


    The answer for the question is YES. FROM clause can be used in UPDATE query. But the example query given is wrong.

    something like this will work

    update table1

    set coulmn=a2.column

    from table1 as a1, table2 as a2

    where a1.colum1 = a2.column2

    Agree.

    Alternatively you can also use

    update table1

    set somecolumn=a2.column

    from table2 as a2

    where column1 = a2.column2

    point here is if you dont specify alias for table to be updated in the from clause you can use it as table name reference. However, if you do specify alias for table1 in table from clause then you must reference the table with alias.

    geervani: In your statement just to keep t-sql cleaner I would use following

    update a1

    set a1.somecolumn=a2.column

    from table1 as a1, table2 as a2

    where a1.column1 = a2.column2