Hi,@ASHMITP
Welcome to Microsoft T-SQL Q&A Forum!
Not tested, but you might try:
select *
From table2
where not exists(
select table1.[Fac]
from table1
where table1.[Fac]=convert(varchar,table2.fac_id + '-' + RIGHT('0000000000'+CAST(table2.MRN AS VARCHAR(10)),10),50)
)
Best regards,
Bert Zhou
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
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.