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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Update Statement using a Join

Author  Topic 

PaulTeal
Yak Posting Veteran

67 Posts

Posted - 2002-11-27 : 14:49:59
Lets say you have two tables,

tblEmployees:

EmployeeNumber EmployeeName SSN
-------------- ------------ ------
1.00 Bob <NULL>
2.00 Greg <NULL>
3.00 Tonya <NULL>


and tblSSN:

EmployeeNumber SSN
-------------- -----------
1.00 374-77-1236
2.00 831-75-4256
3.00 784-25-1245

I know how to write the query to join the two:

SELECT
e.EmployeeNumber,
e.EmployeeName,
s.SSN

FROM
tblEmployees AS e JOIN tblSSN AS s
ON e.EmployeeNumber = s.EmployeeNumber

But I want to write an update statement that will change tblEmployee's SSN column from nulls to the correct social security numbers. None of the update statements in my books use a join to populate data from another table.

Paul Teal
sql@partytilyoupop.com

jung1975
Aged Yak Warrior

503 Posts

Posted - 2002-11-27 : 15:23:33

Here is the link about update from other table using join http://www.sqlteam.com/item.asp?ItemID=3876
Go to Top of Page
   

- Advertisement -