Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Get Triggering Row?
Message
De
11/10/2002 13:08:58
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Conception bases de données
Divers
Thread ID:
00710415
Message ID:
00710431
Vues:
18
This message has been marked as the solution to the initial question of the thread.
SQL Server triggers fire once regardless of the number of rows involved in the command. It will fire once for one row, five rows, or zero rows. Please keep this in mind. All triggers must be capable of handling multiple rows or throwing and error if multiple rows are affected.

Within a trigger, SQL Server will create two tables in memory: Inserted and Deleted. The Inserted table will contain a copy of the rows after the data modifiecation has occurred. The Deleted table will contain a copy of the rows before the data modification has occurred.

Your query would probably look like:

UPDATE Reports
SET Reports.ReportCreatedDate = getdate()
Where reports.id in (
select id from inserted)

-Mike

>Given a painfully simple trigger as follows: How do you get the row firing the trigger for the where clause? RowThatCausedTheTriggerToFire is an elusive prey beast.... :)
>
>CREATE TRIGGER PutDate ON dbo.Reports
>after INSERT
>AS
>UPDATE Reports
>SET Reports.ReportCreatedDate = getdate()
>Where {RowThatCausedTheTriggerToFire}
>
>
>My Humble thanks in advance,
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform