I am trying to write a script that will only insert records that do not exist to a local table. Whenever a form is changed, it keeps the same name, but a new record is created with a new ID. I need to be able to pull the new record by checking for ID's that are not on the local table, but using a form name to isolate. The nested select I am attempting is
select distinct qf.[eform_id]
from [qfiniti].[qfiniti_platform].[dbo].[eval_forms] qf
inner join FORMS_REF fr on qf.[name] collate database_default = fr.form_name collate database_default
where not exists (select fr.eform_id
from forms_ref fr
inner join [qfiniti].[qfiniti_platform].[dbo].[eval_forms] qf on fr.eform_id = qf.eform_id);
It is outputting nothing, but I have intentionally deleted one form record to force it to show up. Any ideas?