January 24, 2002 03:24 PM

Firing a Trigger for Each Inserted Row

Rating: (0)
SQL Server Magazine
InstantDoc ID #23619
Microsoft’s SQL Server development team explains how to get a trigger to fire for each row that you insert....

...This article is for paid Professional Members only.

Already a Professional Member? Please log in now:

NOT A PROFESSIONAL MEMBER? YOU CHOOSE:

Professional Membership

Monthly

Annual

VIP Membership

Monthly

Annual

Add a Comment

Mialem nadzieje, ze jest jakies inne rozwiazanie tego problemu. I have hope that is other solution for this problem.

zenobriusz 6/7/2008 3:42:41 AM


That was the worse answer to someone's problem by Microsoft ever. I can't believe I bought a subsricption to this site just for that. Completely misleading to end the article with a ... one word before it actually ends.

pughdr 4/11/2007 10:42:32 AM


test

mcoffee 1/31/2007 8:56:35 AM


(note: I only have a few years experience here)
I am doing the reverse of a bulk update on the table itself; it may be thought to go to the very table where there is one transaction, that affects the 'bulk insert':
-- "Othertable" is where I am 'mass' updating, this trigger can be put into something called "ThisTable"

-- example: a person deletes a record, it tags associated records, if there is no related table, the "IsOrphan" does not fire, the record is deleted.
-- note: NO RELATIONSHIPS in either table
INSTEAD of delete
AS
Declare @Rcount As int
Declare @RegID As Int


SELECT @rcount = @@rowcount
IF @rcount =0
return


SELECT @RegID= (SELECT deleted.RegID
FROM deleted)

BEGIN
SET NOCOUNT off;
UPDATE OtherTable
SET IsOrphan = 1
WHERE (OtherTable.RegID = @RegID)

dianagele 6/27/2006 5:16:53 PM


How about an answer for how to do this when set based operations are not an option?

Anonymous User 6/13/2005 12:44:36 PM


oooh... so i'll to open a cursor ans loop thru...
Oracle is smart for this. there is a "for each row" clause.

Anonymous User 3/20/2005 6:04:52 AM


test

Anonymous User 1/31/2005 9:32:02 PM


You must log on before posting a comment.

Are you a new visitor? Register Here