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
 General SQL Server Forums
 New to SQL Server Programming
 update from a select based on a join

Author  Topic 

jaycee
Starting Member

18 Posts

Posted - 2012-12-04 : 14:58:51
I am trying to run an update on a table to transfer an id field to an id field in another table where the forename = forename and surname = surname.
In MS Access, I would use:
UPDATE Mar
INNER JOIN mar
ON MyEmployees.FirstName = mar.FirstName
AND MyEmployees.LastName = mar.LastName
SET mar.extraid = Myemployees.employeeid
but in SQL Server 2005 I get errors.
Would the correct TSQL be:
UPDATE Mar
SET Mar.employeeid = Myemployees.EmployeeID,
FROM Mar
INNER JOIN Myemployees ON Mar.Firstname = Myemployees.FirstName
AND Mar.Surname = Mar.Surname

Thanks for any help.

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2012-12-04 : 15:15:03
Yes it would work.
Go to Top of Page
   

- Advertisement -