SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 update from a select based on a join
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jaycee
Starting Member

United Kingdom
18 Posts

Posted - 12/04/2012 :  14:58:51  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

USA
7174 Posts

Posted - 12/04/2012 :  15:15:03  Show Profile  Reply with Quote
Yes it would work.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.78 seconds. Powered By: Snitz Forums 2000