June 27, 2013 at 3:58 pm
Hi,
i have a requirement in sql server 2005 i have 2 tables as follows in both tables column "name" as common
Example :Below is table A
-------------------------------------
name JANclient
----------------------------------------
Srinivas ABC
suraj XYZ
Srinivas KKKK
Raj SSSS
Example:Table B
------------------------------------
name FEBclient
--------------------------------------------
Srinivas AAAA
suraj ZZZZ
mahesh PPP
now i want the result both tables A and B as shown like below
-----------------------------------------------------------------------------------
name JANclient FEBclient
-------------------------------------------------------------------------------------
Srinivas ABC AAAA
Srinivas KKK NULL
suraj XYZ ZZZZ
mahesh NULL PPP
Raj SSSS NULL
please help me
Thanks
June 27, 2013 at 5:15 pm
How do you define that you want to Join Srinivas AAAA with Srinivas ABC but not with Srinivas KKKK?
Could you provide DDL and sample data in a consumable format? That way we can focus on the solution and not on preparing the data to work on it.
June 28, 2013 at 9:25 am
you need to use FULL OUTER JOIN
SELECT ISNULL(t1.name, t2.name) AS name
,t1.JANclient
,t2.FRBClient
FROM Table1 AS t1
FULL OUTER JOIN Table2 AS t2 ON t2.name = t1.name
However, as "name" is highly unlikely to be unique, you are going to have screwed results.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply