20 October 2018        Add to Favorites   Report

UPDATE from another table in Snowflake

The update command can be used to update specified rows in the target table with new values. If you have moved from Teradata, note that in Teradata we have the "from" clause first followed by "set".


update t1
set t1.number_column = t1.number_column + t2.number_column, t1.text_column = 'ASDF'
from t2
where t1.key_column = t2.t1_key and t1.number_column < 10;

Or you can even do a derived table, like the below,

update target set v = b.v
from (select k, min(v) v from src group by k) b
where target.k = b.k;


UPDATE <target_table>
SET <col_name> = <value> [ , <col_name> = <value> , ... ]
[ FROM <additional_tables> ]
[ WHERE <condition> ]