0

UPDATE table1
SET ID,[DESC] =
( SELECT ID,[DESC]
FROM tmptable
WHERE tmptable.ID_SUN = table1.ID_SUN)
WHERE EXISTS
( SELECT ID,[DESC]
FROM tmptable
WHERE tmptable.ID_SUN = [Table1].ID_SUN)
I tired this but i coudn't uptade tow columns at once
do i need to seperate them or i have any mistake?

2
Contributors
1
Reply
4
Views
10 Years
Discussion Span
Last Post by cfAllie
0

Yes, you need to separate them. The syntax should be more like

UPDATE SomeTable
SET   Column1 = SomeValue1,
        Column2 = SomeValue2,
        Column3  = ....

It doesn't look like you need a subquery either. A simple join should be sufficient. Something like

UPDATE t1
SET    t1.ID = tmp.ID,
         t1.[DESC] = tmp.[DESC]
FROM   
        tmptable tmp INNER JOIN table1 t1
        ON tmp.ID_SUN = t1.ID_SUN
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.