Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL Update Help
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

United Kingdom
3 Posts

Posted - 08/18/2010 :  11:04:02  Show Profile  Reply with Quote
Afternoon All

I 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.


Table 1 has a column A which is null, and a column B which contains the 'system_id' value

Table 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 regards

Not Just a Number

15586 Posts

Posted - 08/18/2010 :  11:06:51  Show Profile  Reply with Quote
DDL, sample data and expected results usually help a lot


You'll probably get an answer in minutes



Hint: Want your questions answered fast? Follow the direction in this link

Add yourself!

Go to Top of Page

Starting Member

United Kingdom
3 Posts

Posted - 08/18/2010 :  11:22:50  Show Profile  Reply with Quote
Never been any good at putting things into words :)

To expand...

I am using SQL Server 2005

The 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.

Go to Top of Page

In (Som, Ni, Yak)

17689 Posts

Posted - 08/18/2010 :  23:01:42  Show Profile  Reply with Quote

SET    user_id = P.user_id
       INNER JOIN AJSTMP T ON P.system_id = T.system_id

Time is always against us

Go to Top of Page

Starting Member

United Kingdom
3 Posts

Posted - 08/19/2010 :  02:35:16  Show Profile  Reply with Quote
That's brilliant, look so simple, I assumed it would be more complicated. I'll give it a go, cheers mate
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000