[dba-SQLServer] Triggers To Update A Table When Another Table Has ARecord Inserted

Djabarov, Robert Robert.Djabarov at usaa.com
Fri Apr 2 12:47:32 CST 2004


I'd suggest not to implement a trigger (it's neat and all, but leads to issues you wouldn't want to deal with in the future).  Create a set of stored procedures, - spI_Personnel, spD_Personnel, spU_Personnel, spS_Personnel.  Letters after "sp" denote the action that will be taken on the table (I-nsert, U-pdate, D-elete, S-elect).  Remove all direct access from the table.  This way you know exactly how the data gets affected or displayed, no matter who accesses the table.

Robert Djabarov
SQL Server & UDB
Sr. SQL Server Administrator
Phone: (210)  913-3148
Pager: (210) 753-3148
9800 Fredericksburg Rd. San Antonio, TX  78288
www.usaa.com

-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of paul.hartland at fsmail.net
Sent: Friday, April 02, 2004 8:17 AM
To: dba-sqlserver
Subject: [dba-SQLServer] Triggers To Update A Table When Another Table Has ARecord Inserted

To all,
 
Just starting to play about with Triggers, what I want to do is create a Trigger for a table called tblPersonnel so that when someone adds a new record to the table, the Trigger Executes a stored procedure that updates a table called tblDataChanges with the PayrollNo, DateAdded, Firstname & Surname.
 
Has anyone got any sample code to create this Trigger, I have the Stored Procedure to update the tblDataChanges with the Parameters @Payroll, @DateAdded, @Firstname & @Surname.
 
Thanks in advance for any help on this.
 
Paul Hartland
Freeserve AnyTime - HALF PRICE for the first 3 months - Save £7.50 a month 
www.freeserve.com/anytime
_______________________________________________
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