0

Guys,

Can you help please to compare or check the records from Mytable1 to MyTable2 if exist or found.
and i have to count the records with not null.
Any idea. you can modify my script.

elect 
	a.ESN
    b.ESN
FROM MyTable1 as a
Left outer join Mytable2 as b
on a.esn = b.esn

Create table MyTable1(ESN varchar(10)
Insert into MyTable1
Value('120')
Value('121')
Value('122')
Value('123')
Value('124')

Create table MyTable2(ESN varchar(10)
Value('120')
Value('121')
Value('122')

The result should be like this:
MyTable
ESN
---------
120--120
121--120
122--120
123--NULL
124--NULL

Thank you guys

Jonel

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by adam_k
0

Do you want to count as part of the same select ? Your example result doesn't count.
Anyway, you can count using an outer join.

Since you already have the join written, I'm guessing that you want the results to be in 1 field (like your example result). Then do a select like this:

select table1.ESN + '--' + table2.ESN 
from table1 ....

If you are having problems with NULL (which in the above example will null the whole line) then either use isnull() or SET CONCAT_NULL_YIELDS_NULL OFF (keep in ming that the SET CONCAT_NULL_YIELDS_NULL is being phased out)

Edited by adam_k: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.