[dba-SQLServer] TRIGGER question

Susan Harkins ssharkins at bellsouth.net
Sat Jul 9 17:20:54 CDT 2005


Nevermind -- I don't think I can do what I want to do with such a simple
trigger. 

What I've got only records the DML action once. If the action acts upon
multiple records, there's still only one record in the table. So, passing
the record's primary key value isn't valid anyway. 

Is it possible to record each record changed by a DML trigger, as opposed to
what I'm doing? 

Susan H. 

Have you tried @@IDENTITY ?

Hth
Steve


-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Susan
Harkins
Sent: Saturday, July 09, 2005 4:48 PM
To: SQLList
Subject: [dba-SQLServer] TRIGGER question


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. 

_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com


_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com





More information about the dba-SQLServer mailing list