Hi Kirk,
Keep in mind that a trigger fires only once per SQL statement regardless of how many records are affected by that statement. A trigger has acces to the changed records through the special
deleted and
inserted tables. The deleted or updated records (old values) are stored in a
deleted table. The inserted or updated records (new values) are stored in a
inserted table.
BTW, it's good idea to preview message before posting to make sure that it's readable.
>The following code works in my trigger, but on the last two If's, I want to record what the new status is. For instance, the Active Case Status = ACTIVE or Active Case Status = CANCELLED. the isCancelled field is a bit. This trigger is be generated to record key events that happen to a record. Does anyone know how to do this, this is my one an only trigger and I'm learning.
>
>Thanks for any Help.
>
>
>declare @tcAction varchar(500)
>set @tcAction=' '
>
>if update(begintime) or update(RoomID) or update(isCompleted) or update(isCancelled)
> begin
> if update(Begintime)
> set @tcAction='Scheduled Time/Date Changed '+'New Start= '
> if Update(RoomID)
> set @tcAction=@tcAction+'Room Changed'
> if update(BlockMember)
> set @tcAction=@tcAction+'Block Membership Changed'
> if update(isCancelled)
> set @tcAction=@tcAction+'Active Case Status Changed'
> if update(isCompleted)
> set @tcAction=@tcAction+'Case Finalized Status Changed'
> INSERT INTO Audit_Meeting(meetingnumber,begintime,endtime,patientID,roomid,
actualRoomID,ScheduledBy,BlockMember,LastAuditForm,LastAuditBy,deptID)
> (SELECT meetingnumber,begintime,endtime,patientID,roomid,
actualRoomID,ScheduledBy,BlockMember,@tcAction,dbo.get_login_name(),DeptID
> from deleted)
> end
>
>
--sb--