Please start any new threads on our new site at http://forums.sqlteam.com. 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
 
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
 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  
 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.06 seconds. Powered By: Snitz Forums 2000