|
sql
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
trigger for Inserting question
Hi,
In my SQL Server 2000, I want to create an Insert trigger. If inserting into TableA, then it will also insert into TableB. What will the solution be like? Thanks for help. Jason Here's a generic skeleton for such a trigger:
CREATE TRIGGER myTrigger ON TableA AFTER INSERT AS IF @@ROWCOUNT = 0 RETURN INSERT INTO TableB (col1, col2, ...) SELECT col1, col2, ... FROM inserted GO See Books Online, CREATE TRIGGER for more information. -- Show quoteHide quoteTibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp http://www.solidqualitylearning.com/ "Jason Huang" <JasonHuang8***@hotmail.com> wrote in message news:%236V5R0ASGHA.5552@TK2MSFTNGP14.phx.gbl... > Hi, > > In my SQL Server 2000, I want to create an Insert trigger. > If inserting into TableA, then it will also insert into TableB. > What will the solution be like? > Thanks for help. > > > Jason > |
|||||||||||||||||||||||