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 Administration
 Need help with an update

Author  Topic 

cgcourson
Starting Member

3 Posts

Posted - 2013-01-31 : 16:47:27
I am familiar with updates on one table but not when data spans two tables, so any help would be greatly appreciated.

I have a spreadsheet with pricing by model number and I need to update a pricing table in the database...here is the problem..

In the DB, my products_tbl has a product_id and a product_model

the table I need to update (products_groups) only has the product_id and price so the update query I need to write needs to find the products_id for a products_model then update the price.

I will need to do this on 20,000+ rows so will need to concatenate in SQL which is no problem, but the query will be difficult for me. sorry if explanation is a little difficult to understand

THanks in advance to whomever can lend a hand
Chris

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2013-01-31 : 20:21:18
Dump ExcelSheet into TempTable. If you need to do regularly you can do through SSIS Package

Update pg
Set pg.Price = T.Price
from Product_tbl pd
inner join Temptable T on T.product_model = pd.product_model
inner join products_groups pg on pg.product_id = pd.product_id
Go to Top of Page
   

- Advertisement -