Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Bulk Updating

Author  Topic 

Rhowin
Starting Member

2 Posts

Posted - 2010-01-07 : 05:23:18
Hi everyone,

I have basically the following task ahead: I want to update the values of one table with a second table, e.g. I have one table A with 1000 products and a second one B with the updates of some attribute for 200 of these already existing products in A. With the "update" command and a loop I know how I can easily update each entry one by one - but this seems quite unefficient and I bet there is a more elegant command for this as this seems a very common task.

Thank you for any inputs

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-01-07 : 05:26:45
no need of loop. just do

UPDATE a
SET a.fieldval=b.fieldval,..
FROM A a
JOIN B b
ON a.ProductID= b.ProductID
Go to Top of Page

Rhowin
Starting Member

2 Posts

Posted - 2010-01-08 : 04:34:11
Thank you
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-01-08 : 10:39:51
welcome
Go to Top of Page
   

- Advertisement -