If no values found using joins then update as values as 'Exclude'

12 Views Asked by At

I wrote a trigger, where after loading the data from SSIS package, it will update the two columns based on join using ID:

Create trigger Update_CRM on CRM After Insert as begin declare @date date set @date = ( SELECT MAX(CAST([Entry Date] AS DATE)) FROM CRM ) update CRM set CRM.[Name] = TADC.[Name], CRM.[Group] = TADC.[Group] from CRM CRM left join History TADC ON CRM.ID = TADC.ID AND cast(CRM.[Entry Date] as Date) = TADC.[Date] where CAST(CRM.[Entry Date] as date) = @date AND CRM.[ECC Group] is null END

Above trigger works well. But since its a join, if no value is found, the cell values are left NULL.

Is there a way to write statement inside the trigger, if no value found in joined table, then update cell values as 'Exclude'?

Thank You

0

There are 0 best solutions below