• Sean Lange (3/12/2013)


    robertd 77391 (3/12/2013)


    A simple way to do this:

    update #Table1

    set #Table1.SID = #Table2.aID

    from #Table2

    where #Table1.Sno = #Table2.Sno ;

    I can't for the life me remember the details but there is an issue when you do an UPDATE FROM and the table being updated is not in the query. It is better to use the join method as demonstrated by Alan above.

    I think what is needed for this would be this:

    update #Table1

    set SID = (SELECT #Table2.aID from #Table2 where #Table1.Sno = #Table2.Sno) ;