Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 JOINED column - NO data

Author  Topic 

duanecwilson
Constraint Violating Yak Guru

273 Posts

Posted - 2010-06-18 : 11:09:30
This join returns no data in the last two columns. I am looking at, in particular, empid on second line.<br/>
As you can see, WB_LOGON_ID is in WB_WF_EMPLID_XREF AND #t. What am I missing?<br/>
The second line of table #t should have A767108 in WB_LOGON_ID in results and 00001836553 in X_EMPLID<br/>
What am I missing here? In the real query there are 2300 rows and NO data in the last 2 columns<br/>
<pre lang="x-sql">select DISTINCT #t.*, X.EMPLID X_EMPLID, X.WB_LOGON_ID from #t
left join WB_WF_EMPLID_XREF X on X.WB_LOGON_ID = #t.empid

Results:
lastname firstname empid EMPLID EMAIL_ID X_EMPLID WB_LOGON_ID
Smith Thomas 00001427232 00001427232 Tom.J.Smith@randomemail.com NULL NULL
McWilliams Timothy A767108 NULL NULL NULL NULL
Walton Donald A819301 NULL NULL NULL NULL

Table WB_WF_EMPLID_XREF:
EMPLID WB_LOGON_ID WB_EMPLID
00001836553 A767108 992947

As you can see, even though only one record is shown, the data IS in WB_WF_EMPLID_XREF. I did check the length of
both columns and they were 7, so there were no spaces.

Duane

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-06-18 : 12:19:13
You haven't provided data from both your tables, but just a guess shouldn't it be
left join WB_WF_EMPLID_XREF X on X.EMPLID = #t.empid
instead of
left join WB_WF_EMPLID_XREF X on X.WB_LOGON_ID = #t.empid

Go to Top of Page
   

- Advertisement -