Nicholson, Karen
knicholson at gpsx.net
Fri May 23 16:07:26 CDT 2003
Never mind - I was able to figure out the current record thing. As simple as defining the keys in the table where they equal the insert.key fields. YEEE HAAA -----Original Message----- From: Djabarov, Robert [mailto:Robert.Djabarov at usaa.com] Sent: Friday, May 23, 2003 1:27 PM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer]Update Trigger Something like that may work, but you need to check. if object_id('trigI_System') is not null drop trigger trigI_System go create trigger trigI_System on [System] for insert as if update(CS_No) begin insert Recur_Line (Service_Site_No, UDF1) select Site_no, CS_No from inserted if @@error != 0 begin raiserror('Failed to insert into Recur_Line!', 15, 1) rollback transaction end end GO Robert Djabarov Senior SQL Server DBA USAA IT/DBMS ? (210) 913-3148 - phone ? (210) 753-3148 - pager -----Original Message----- From: Nicholson, Karen [mailto:knicholson at gpsx.net] Sent: Friday, May 23, 2003 2:13 PM To: SQL Server List (E-mail) Subject: [dba-SQLServer]Update Trigger I need to create an update trigger on a table to update a field in another table. This is the scope: Originating table: System /**I did not name it, proprietary package**/ Field: CS_No Key Field: Site_no Destination Table: Recur_Line Field: UDF1CS_no Key Field: Service_Site_No Scenario: When the user is in the system, he enters in a CS_No in the table(System) field(CS_No). I need this to populate the UDF1CS_no field in the Recur_Line table when the System.Site_no=Recur_Line.SiteNo This is my first "cross pollinating" trigger as I refer to it. Does anyone have an example? Thanks, gurus. Karen Nicholson SQL Database Administrator Guardian Protection Services _______________________________________________ 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