Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trigger is locking up record
Message
 
 
À
29/04/2004 08:10:31
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00899034
Message ID:
00899275
Vues:
20
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--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform