Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
UPDATE() in triggers
Message
From
22/10/2003 11:02:18
Jenny Karlsson
Megasol Technologies
Uppsala, Sweden
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
Other
Title:
UPDATE() in triggers
Miscellaneous
Thread ID:
00841063
Message ID:
00841063
Views:
45
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
Next
Reply
Map
View

Click here to load this message in the networking platform