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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 update from multiple tables
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

ppatel112
Starting Member

26 Posts

Posted - 10/02/2013 :  01:19:11  Show Profile  Reply with Quote
Hi Folks,

i am using 4 tables company, users, ARSAP, ARCUS to update a column in company table.

the tsql i am using is below.

UPDATE c
SET c.comp_primaryuserid = u.user_userid
FROM Company c, Users u
LEFT JOIN SAMINC.dbo.ARSAP z on z.NAMEEMPL = 'u.user_firstname u.user_lastname'
LEFT JOIN SAMINC.dbo.ARCUS y on z.CODESLSP = y.CODESLSP1 WHERE y.IDCUST = c.comp_companyid

the validation "LEFT JOIN SAMINC.dbo.ARSAP z on z.NAMEEMPL = 'u.user_firstname u.user_lastname'" is not working though the sql is correct, there is no relation between ARSAP table and users table.

I just want to match the firstname lastname from column NAMEEMPL (table ARSAP) to users table user_firstname user_lastname.

i am stuck at this point and i cant update c.comp_primaryuserid = u.user_userid to fix this up.

any ideas to help?

regards,
parth

tkizer
Almighty SQL Goddess

USA
36613 Posts

Posted - 10/02/2013 :  06:17:37  Show Profile  Visit tkizer's Homepage  Reply with Quote
Is this what you mean?

LEFT JOIN SAMINC.dbo.ARSAP z on z.NAMEEMPL = u.user_firstname + ' ' + u.user_lastname

Is NAMEEMPLE always firstname <space> lastname?

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
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.05 seconds. Powered By: Snitz Forums 2000