AFTER INSERT trigger

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Just D. (no_at_spam.please)
Date: 08/19/04


Date: Thu, 19 Aug 2004 13:34:42 -0700

All,

How this trigger should be fired if I insert for example 400-500 records? I
suspect that the trigger will be fired only once when all records are
inserted, is it true?

I'd like to work with every inserted record separately, what should I do for
that? To write this code in the trigger, like:

WHILE (SELECT COUNT (ID) FROM SomeTable WHERE ID IS NULL )
...Some code...

Is it correct?

And how can I parse the variables from the inserted record? I know about
INSERTED but if I add a semicolon ; then this doesn't work anymore.

Just in two words - the schema is simple - I INSERT many records from some
remote database and I need a trigger to propagate these values to some
database tables from the bridge table. I need to parse all these values one
by one and INSERT these records in another table on the same MSSQL server.
What I need to get - I need to get all fields one by one inserted by remote
database, create an INSERT string to insert this data into another one
database table and finally to get an assigned record ID from this database
table and UPDATE this value on the bridge table only for the record I was
working with.

Just D.



Relevant Pages

  • Re: Error 2950 - Reserved Error on form refresh/requery
    ... and I can't leave the client with an unusable database while I try to ... The requery is on the form (so the data displayed in the sub-forms refreshes ... The triggering event is a listbox after update that does 2 things only: ... can trigger others, and so the problem may occur only when a specific ...
    (microsoft.public.access.formscoding)
  • Re: Help with INSERT TRIGGER - fails with error.
    ... You didn't declare any PRIMARY KEY in this database. ... In an INSERT trigger, ... but I can't get it to work because it references ntext fields. ...
    (comp.databases.ms-sqlserver)
  • Re: Lookup Tables, the right way?
    ... model is comes in un-learning what you know about file systems. ... The users might not all have the same database access rights ... This rule would be enforce by a REFERENCES ... with a trigger that you can do with DRI and more. ...
    (comp.databases.theory)
  • Re: Using one table vs. many
    ... model is comes in un-learning what you know about file systems. ... The users might not all have the same database access rights ... This rule would be enforce by a REFERENCES ... with a trigger that you can do with DRI and more. ...
    (comp.databases)
  • Re: Safe delete idea for discussion
    ... to use a stored procedure instead of trigger ... select getdate, 'AuditLog', AuditLogID ... > restore database Recovery ... >>> that writes an entry into a DeleteLog table ...
    (microsoft.public.dotnet.framework.aspnet)