Hi @ahmed salah ,
Please also refer another method below:
select c.*,
case when d.PartId is null then 'NotExist' else 'Exist' end Status from
(select distinct PartId,b.ZFeaturekey from #features a
cross apply #categoryfeatures b) c
left join #features d
on c.PartId=d.PartId and c.ZFeaturekey=d.ZFeaturekey
Output:
PartId ZFeaturekey Status
12222 8090 NotExist
12222 9090 NotExist
12222 45555 Exist
12222 46788 Exist
12222 98342 NotExist
54449 8090 NotExist
54449 9090 NotExist
54449 45555 NotExist
54449 46788 NotExist
54449 98342 Exist
Best regards
Melissa
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Hot issues November--What can I do if my transaction log is full?
Hot issues November--How to convert Profiler trace into a SQL Server table