Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
UPDATE() in triggers
Message
De
22/10/2003 11:02:18
Jenny Karlsson
Megasol Technologies
Uppsala, Suède
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Titre:
UPDATE() in triggers
Divers
Thread ID:
00841063
Message ID:
00841063
Vues:
46
I would like to update all rows in table1 where the column amount
had been updated, if column amount hasn't been updated go to next row.
I would like to do this check UPDATE(amount) for each row in cursor. I think this code loop through all posts in inserted and not only the ones where amount had been updated. Can anybody give me a solution for this problem?
CREATE TRIGGER tr_Name
ON dbo.table1
FOR INSERT, UPDATE
AS

IF UPDATE(amount)
BEGIN
        DECLARE curInserted INSENSITIVE CURSOR FOR 
		SELECT date, idnr, amount
		FROM inserted
		ORDER BY date

	OPEN curInserted
	FETCH NEXT FROM curInserted
	INTO @ldDate, @lcIdNr, @lnAmount

	WHILE @@FETCH_STATUS = 0
	BEGIN
		....code...
	
		FETCH NEXT FROM curInserted
		INTO @ldDate, @lcIdNR
	END
END
Regards Jenny
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform