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
 Updating table

Author  Topic 

Vack
Aged Yak Warrior

530 Posts

Posted - 2010-01-20 : 15:09:25
How do you join a table in an update statement??

I have a view called oldqty2 and a table called iminvloc_sql.




update iminvloc_sql
set tag_qty = NewQty
join [oldqty2] on [oldqty2].item_no = iminvloc_sql.item_no
where [oldqty2].doc_type <> 'A' or [oldqty2].doc_type <> 'H'

Vack
Aged Yak Warrior

530 Posts

Posted - 2010-01-20 : 15:18:51

got it figured out.

UPDATE iminvloc_sql
SET iminvloc_sql.tag_qty = [oldqty2].NewQty
FROM [oldqty2] WHERE [oldqty2].item_no = iminvloc_sql.item_no and [oldqty2].loc = iminvloc_sql.loc and ([oldqty2].doc_type <> 'A' or [oldqty2].doc_type <> 'H')
Go to Top of Page
   

- Advertisement -