Over the next few days we are going to start the migration to a new forum application. I'm going to start with high post count and active users. You may receive an invitation to the new forums. It's not spam. It's just me trying to seed the user base. My goal is to open it up over the weekend.

Once we open the site we'll block registrations here. We should be open shortly on the new site.

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

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
38194 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