[dba-SQLServer] TRIGGER question

Susan Harkins ssharkins at bellsouth.net
Sat Jul 9 15:48:13 CDT 2005


CREATE TRIGGER AuditRoyaltyUpdateInsert ON dbo.roysched
FOR INSERT, UPDATE
AS
DECLARE @precordID varchar(6)

IF UPDATE(royalty)
  INSERT INTO auditable (actiondescription, recordID, actionuser,
actiondate)
   VALUES ('U', @precordID, User_Name(), GetDate())
ELSE
 INSERT INTO auditable (actiondescription, recordID, actionuser, actiondate)
   VALUES ('I', @precordID, User_Name(), GetDate())
 
=========The above trigger started  out as a simple audit trigger. Then, I
decided to add the table's primary key value to the audit record, and I
don't know how to do it -- how do I pass the current record's primary key
value, being dbo.roysched.title_id to the @precordID variable? 
 
Susan H. 




More information about the dba-SQLServer mailing list