Link to home
Start Free TrialLog in
Avatar of Steve
SteveFlag for United States of America

asked on

Left join issue

I need to write a query that returns all rows from tableA that do not exist in tableB where tableB is in another database.  I can't use a simple sub-select so I have to use a left join, I think...  The problem is that the query is returning to many rows so I must not have it right.
select *
from tableA a
	left join server.db.owner.tableB a1 on a.number = a1.number
where a1.number is null

Open in new window

Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

the query is correct syntax.
so, if you get too many records, then you have a data type issue, probably.
what is the data type (and collation) of the fields "number" in the 2 tables.
Avatar of Steve

ASKER

The data types are nvarchar and char.  That would lead me to believe the collations are different, unicode versus non-unicode.
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Steve

ASKER

No luck guy, I still have the same number of rows as when I don't cast...
What is the output of your query and what is your expected result. give an example.
Avatar of Steve

ASKER

Ugh, nevermind, I think I just found it.  Thanks for your help!!  Points are yours.