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

ppatel112
Starting Member

35 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
38200 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  
 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.04 seconds. Powered By: Snitz Forums 2000