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.
| Author |
Topic |
|
tchinedu
Yak Posting Veteran
71 Posts |
Posted - 2005-11-17 : 11:19:34
|
| Please help guys,I'm basically trying to update one table from values in another tableI need to create a procedure that goes thru and updates my tables based on the new values I have in a temp table...this is just to give an idea of what I'm trying to doCreate Procedure UpdateGroupingMapasupdate GroupingMap set GroupingMap.GroupNumber = TempTable.GroupNumber Where GroupingMap.Gr_ID = TempTable.Gr_ID and GroupingMap.p_ID = TempTable.p_IDPlease help |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2005-11-17 : 11:23:20
|
quote: Originally posted by tchinedu Please help guys,
ues that leaves you out Taraquote: I'm basically trying to update one table from values in another tableI need to create a procedure that goes thru and updates my tables based on the new values I have in a temp table...
OK, should be simple enough...follow the hint link in my sig and post some info for usBrett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxAdd yourself!http://www.frappr.com/sqlteam |
 |
|
|
tchinedu
Yak Posting Veteran
71 Posts |
Posted - 2005-11-17 : 11:44:36
|
| basically I have a temp table with columns: - pr_ID and gr_ID and gr_num. pr_id and gr_id are the combo key. all cols are int typeexample datapr_ID gr_ID gr_num1 --- 345 --- 12 --- 654 --- 33 --- 567 --- 14 --- 345 --- 25 --- 123 --- 16 --- 987 --- 2 etcand a destination table with same columns, I want to update the destination table with values from tempTable. my application has done some calculations and changed the temp table groupNumber values, and I want to update all groupNumber's in the destination table with values from the temp table. |
 |
|
|
tchinedu
Yak Posting Veteran
71 Posts |
Posted - 2005-11-17 : 11:55:18
|
| Would this do it...Create Procedure UpdateGroupingMapasupdate GroupingMapset GroupNumber = (select GroupNumber from GroupingTempTable s, GroupingMap c where c.gr_ID = s.gr_ID and c.p_ID = s.p_ID) |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-11-17 : 23:38:38
|
| update c set c.GroupNumber = s.GroupNumber from GroupingMap c inner join GroupingTempTable s, on c.gr_ID = s.gr_ID where c.p_ID = s.p_IDMadhivananFailing to plan is Planning to fail |
 |
|
|
tchinedu
Yak Posting Veteran
71 Posts |
Posted - 2005-11-18 : 16:44:18
|
| Thank you so much... |
 |
|
|
|
|
|