Hello List,
I was asked to add a column (N_count int) in a table. It will record how many times that each row is inserted or updated in the table.
I wrote a trigger to do this, but it has a bug in it. I don't know to fix it. Could you help me?
Thank you.
Create trigger [PMDB].[TG_count]
on [PMDB].[Alias_A] after insert, update
as
begin
if update(TableName) or update(PK) or update(FieldName) or exists (select * from deleted)
set N_count = N_count + 1
end
Msg 102, Level 15, State 1, Procedure TG_count, Line 6 [Batch Start Line 0]
Incorrect syntax near '='.