Nicholson, Karen
knicholson at gpsx.net
Fri May 23 15:10:09 CDT 2003
OK. This got me farther, but now I am suffering from MS-VBA withdrawal. I am used to being able to put event procedures on a form to just select the current record. This is a proprietary package, so I can not make changes to the form. How do you select the current record? Is that possible? I don't want to update all records in the table as this is a default update, the user may change the value in certain situations. Thanks. -----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