Link to home
Start Free TrialLog in
Avatar of Seven price
Seven priceFlag for United States of America

asked on

update second table

I would like to know if table 2 had a price change how would I update table1 or check if there is any updates from table 2 so i may insert into table1.  Do I have to also check the producid's and past this or can i do it from a select.  what would be the correct syntax


Begin
If Exists (SELECT ProductID, price from table1 where user=@user)

update table1 set price=price
 where user=@user

else
Insert into table1
(productid, price)

select productid, price from Table2
End
ASKER CERTIFIED SOLUTION
Avatar of Stephan_Schrandt
Stephan_Schrandt
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Seven price

ASKER

tks