Member of the LearnItFirst.com Video Training Network | LearnSqlServer.com | SQL SSIS Training | SQL Programming Tutorials |
LearnSqlServer.com Forums LearnSqlServer.com
Welcome Guest Search | New Posts | Members | Log In | Register

Update table based on condition Options
mats_95
Posted: Saturday, May 24, 2008 11:57:48 AM
Rank: Newbie

Joined: 5/24/2008
Posts: 1
Points: 3
Location: UAE
I have 2 tables A- columns id & Amount.
Table A
Id Amount
1 10
2 20
3 30
Another table B columns id,Total_Amount,Product
Table B
Id Total_Amount Product
1 Apple
3 Mango
5 Orange
Now I want to update B with the Amount in A where A.id=B.Id
can u give me a script for this in MS SQL server 2000.I am a newbie.
Scott Whigham
Posted: Monday, May 26, 2008 7:09:17 AM


Rank: Super Mod

Joined: 3/20/2006
Posts: 345
Points: 748
Location: Dallas, TX
Something akin to this:
Code:
UPDATE tableB
  SETAmount = a.Amount
  FROM tableB b JOIN tableA a
     ON A.id=B.id
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
     
Don't Forget!
LearnItFirst.com
Don't Forget!
LearnExchange.com
 
Home | About Us | Support | Contact Us | Privacy | Site Map | Blogs Blogs Refer a Friend and Get a Free Subscription!
© Copyright 2004-2007 LearnItFirst.com LLC. All rights reserved. All trademarks remain the property of their respective owners.
This site is not affiliated in any way with the Microsoft Corporation.