sql - UPDATE a field in one table with the SUM of another -
i'm trying set value of field in table sum of set of fields in table by:
update table1 set fieldtoupdate = ( select sum(fieldtosum) table2 ) thirdfield = 'a'
but i'm not having luck. i've seen lot of examples use joins, 2 tables aren't related in way.
thanks
while subquery should work, break this:
declare @s int; select @s = sum(fieldtosum) dbo.table2; update dbo.table1 set fieldtoupdate = @s fieldtoupdate = 'a';
Comments
Post a Comment