Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Hi,
New to SQL Server Triggers. My understanding is that when a field is updated, the old row is inserted into a temporary table called 'deleted' and the new data is written into a temporary table called 'inserted'.
I'm trying to access the new data in a trigger (in order to update a second table) by doing a select on the 'inserted' table. The problem: the select on the 'inserted' table never returns any rows. Is this the right approach? If not, what would be the right approach?
The code within the trigger:
CREATE TRIGGER trUpdateAnalVerification ON
[ERA_IL_Study_Analytes_Verification]
FOR UPDATE AS
DECLARE newdata2 CURSOR FOR
SELECT study FROM inserted
OPEN newdata2
/*See if any rows were opened*/
INSERT gerrystest VALUES(CAST(GETDATE() AS varchar(25)) + ', after open, ' + CAST(@@ROWCOUNT as char(5)
CLOSE newdata2
DEALLOCATE newdata2
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement