views:

43

answers:

2

I am using this script, trying to join 2 tables with 3 conditions and update T1:

Update T1 set T1.Inci = T2.Inci 
ON T1.Brands = T2.Brands 
AND T1.Category= T2.Category
AND T1.Date = T2.Date

but i encounter: Incorrect syntax near the keyword 'ON'. can't figure it out why

+2  A: 

You need to do

Update table_xpto
set column_xpto = x.xpto_New
    ,column2 = x.column2New
from table_xpto xpto
   inner join table_xptoNew xptoNew ON xpto.bla = xptoNew.Bla
where <clause where>

If you need a better answer, you can give us more information :)

Bruno Costa
you could add a link to sql update syntax.
Stefan Steinegger
You're righthere: http://msdn.microsoft.com/en-us/library/ms177523.aspx
Bruno Costa
A: 
UPDATE
    T1
SET
    T1.Inci = T2.Inci 
FROM
    T1
INNER JOIN
    T2
ON
    T1.Brands = T2.Brands
AND
    T1.Category= T2.Category
AND
    T1.Date = T2.Date
Robin Day