I have 2 tables(label and product) both has the column called uniqueCode which is nvarchar(255) datatype and nullable column.
product table has 30,000 records and label table has 5000 records. I would like to get the uniqueCode from label which doesn't exist in the product table upc column. I tried with not in but returns null data but i have 3000 unmatched data that needs to be displayed. Then i tried with join and it is taking 10+ minutes to provide the result.
select * from label where not in(select uniqueCode from Product where uniqueCode is not null) and uniqueCode is not null
The above query returns null though it has records to show up
FROM label pp
LEFT JOIN Product p ON pp.uniqueCode <> p.uniqueCode
p.uniqueCode is not NULL
[Note : both the columns are non indexed column]
Am i missing anything in this query ? why it is taking too much time to execute. Any suggestions....