IF Exists(Select * From inserted Where ContactId > 10)
BEGIN
Insert Into Person.ContactLog
( ContactID,Action )
Select
ContactID
'Update'
From
inserted
Where
ContactId > 12
END
Jeff I have a question about the need to check for existance when nothing is being done on the else statement.
Does this not create added overhead because if it doesn't exist it's filtered by the where clause of your select statement.
I'm asking because in one of our systems we had a
if (select count(*) from inserted) = 0 then
return
update MyTable
set modifieddate = getdate()
inner join inserted on
Mytable.ID = inserted.ID
When we commented out our if statement we saw a huge improvement in execution speed of the trigger.