We have triggers on 3 of our tables and when you change a column it gets dumped into 2 log tables by the triggers. When we upgraded from SQL2K to SQL2005 somehow the timestamp (which is actually the getdate()) is no longer being populated, it is now null. Not sure how that was working because the column "time_stamp" was not on the insert line of the trigger (see below.) Should I add the column into the insert and select statement or in SQL2005 is it better handled with a constraint? If a constraint is better can you share an example?
Thanks
Smatthews
originial trigger:
ALTER trigger [Name_Delete] on [dbo].[Name]
for delete as
begin
insert Log_Main(ACTION_TYPE,TABLE_NAME,KEY_CLUSTER)
select 4,'Name',ID
from deleted
end
would these new changes work or is there a better way:
ALTER trigger [Name_Delete] on [dbo].[Name]
for delete as
begin
insert Log_Main(TIME_STAMP,ACTION_TYPE,TABLE_NAME,KEY_CLUSTER)
select GETDATE(),4,'Name',ID
from deleted
end
Thanks
Smatthews
originial trigger:
ALTER trigger [Name_Delete] on [dbo].[Name]
for delete as
begin
insert Log_Main(ACTION_TYPE,TABLE_NAME,KEY_CLUSTER)
select 4,'Name',ID
from deleted
end
would these new changes work or is there a better way:
ALTER trigger [Name_Delete] on [dbo].[Name]
for delete as
begin
insert Log_Main(TIME_STAMP,ACTION_TYPE,TABLE_NAME,KEY_CLUSTER)
select GETDATE(),4,'Name',ID
from deleted
end