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 |
osimandeus
Starting Member
3 Posts |
Posted - 2010-08-18 : 11:04:02
|
Afternoon AllI hope this all makes sense!I am trying to update values in a table from another table. The table to be updated has a column containing a value that matches a system_id value on the other table. I effectively want to match the system_id and update a different column with the result.SoTable 1 has a column A which is null, and a column B which contains the 'system_id' valueTable 2 has a column A containing the 'system_id' value and a column B containing a value that I want to add to column A on table 1.Clear as mud, but any help would be greatly appreciated!Kind regardsAndrew |
|
X002548
Not Just a Number
15586 Posts |
|
osimandeus
Starting Member
3 Posts |
Posted - 2010-08-18 : 11:22:50
|
Never been any good at putting things into words :)To expand...I am using SQL Server 2005The first table is called PEOPLE and contains a system_id and a user_id.The second table, a temporary holding table called AJSTMP has a blank user_id column and a column containg the system_id, plus a whole host of other columns.I need to get the user_id into the AJSTMP table in one swoop hopefully - there are approx 8,000 records to update.CheersAndrew |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-08-18 : 23:01:42
|
[code]UPDATE TSET user_id = P.user_idFROM PEOPLE P INNER JOIN AJSTMP T ON P.system_id = T.system_id[/code] KH[spoiler]Time is always against us[/spoiler] |
|
|
osimandeus
Starting Member
3 Posts |
Posted - 2010-08-19 : 02:35:16
|
That's brilliant, look so simple, I assumed it would be more complicated. I'll give it a go, cheers mate |
|
|
|
|
|