HOW DO I CREATE STORED PROCEDURE / TRIGGER IN SQLSERVER 2005
Posted on 2007-12-06
My questions is the following. I have an MS access program that allows users to enter detailed event logs. However, I want to create a trigger in MSSQL SERVER 2005 and be able to update the table T_LOG based on the event type added at T_LogEvents.
So for example. If a created the following record in T_LOGEVENTS...
-EventID: 05513546 (this is an autonumber)
-EventDate: 12/12/07 11:53
-ToFrom: Paula Jones
I want to the trigger in SQL2005 to acknowledge the add in T_LOGEVENTS, and then update the record in T_LOG, lets say SELECT DN_NUMBER FROM T_Log WHERE (DN_NUMBER = N'EP071105001'), and if column DBO.T_LOGEVENTS.LogAction ="NOTIFIED", then the trigger will update the T_LOG record with the following ... dbo.T_LOG.enotify=dbo.T_LogEvents.EventDate, AND T_Log.eLastEventBy=dbo.T_LogEvents.LogUser
Below are my tables. There is a relation of one (t_log) to many (t_logevents)
-EventId...(PK) numeric(18,0)... identity increment 1
Obviously the syntax is not correct, but I am so green in trigger, never dealt with them, so I'll need a step by step on how to create this trigger.