Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Trigger is locking up record
Message
 
 
To
29/04/2004 08:10:31
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00899034
Message ID:
00899275
Views:
21
This message has been marked as a message which has helped to the initial question of the thread.
Rollin,

A trigger fires once per SQL statement regardless of how many records are affectet by it. The trigger code has to take that into account. Your TESTING2 trigger is recurcive because it updates it's own table. You've to put check to prevent such recurrsion.
--
CREATE TRIGGER [TESTING] ON dbo.Table1
FOR INSERT, UPDATE
AS

insert into Table2 (TT2Data1) 
	SELECT testingTable1ID from inserted 

--
CREATE TRIGGER [TESTING2] ON dbo.Table2
FOR INSERT, UPDATE
AS

DECLARE @testingTable2ID int
DECLARE @Data2	char(10)

SET @testingTable2ID = (SELECT testingTable2ID from inserted)

IF NOT UPDATE(TT2Data2)
	update Table2
		set TT2Data2 = 'whatever'
		where testingTable2ID IN (SELECT testingTable2ID from inserted)
		
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform