Showing posts with label fires. Show all posts
Showing posts with label fires. Show all posts

Friday, March 23, 2012

Insert trigger for bulk insert

In case of a bulk insert, the “FOR INSERT” trigger fires for each recod or
only once?
Thanks,
Only once, and ALL of the rows are in the inserted table.
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
You can't help someone get up a hill without getting a little closer to the
top yourself.
- H. Norman Schwarzkopf
"JIM.H." <JIMH@.discussions.microsoft.com> wrote in message
news:B90E6B36-CA4C-49C0-B4C2-268CA0A241A7@.microsoft.com...
> In case of a bulk insert, the "FOR INSERT" trigger fires for each recod or
> only once?
> Thanks,
>
|||To add to Arnie's response, the trigger is fired one for each batch of
records and only if FIRE_TRIGGERS is specified.
Hope this helps.
Dan Guzman
SQL Server MVP
"JIM.H." <JIMH@.discussions.microsoft.com> wrote in message
news:B90E6B36-CA4C-49C0-B4C2-268CA0A241A7@.microsoft.com...
> In case of a bulk insert, the “FOR INSERT” trigger fires for each recod or
> only once?
> Thanks,
>
|||Hi Jim
The BULK INSERT statement has a FIRE_TRIGGERS option and BCP has it as a
hint, to make INSERT triggers fire. See Books Online for more.
John
"JIM.H." wrote:

> In case of a bulk insert, the “FOR INSERT” trigger fires for each recod or
> only once?
> Thanks,
>

Insert trigger for bulk insert

In case of a bulk insert, the â'FOR INSERTâ' trigger fires for each recod or
only once?
Thanks,Only once, and ALL of the rows are in the inserted table.
--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
You can't help someone get up a hill without getting a little closer to the
top yourself.
- H. Norman Schwarzkopf
"JIM.H." <JIMH@.discussions.microsoft.com> wrote in message
news:B90E6B36-CA4C-49C0-B4C2-268CA0A241A7@.microsoft.com...
> In case of a bulk insert, the "FOR INSERT" trigger fires for each recod or
> only once?
> Thanks,
>|||To add to Arnie's response, the trigger is fired one for each batch of
records and only if FIRE_TRIGGERS is specified.
--
Hope this helps.
Dan Guzman
SQL Server MVP
"JIM.H." <JIMH@.discussions.microsoft.com> wrote in message
news:B90E6B36-CA4C-49C0-B4C2-268CA0A241A7@.microsoft.com...
> In case of a bulk insert, the â'FOR INSERTâ' trigger fires for each recod or
> only once?
> Thanks,
>|||Hi Jim
The BULK INSERT statement has a FIRE_TRIGGERS option and BCP has it as a
hint, to make INSERT triggers fire. See Books Online for more.
John
"JIM.H." wrote:
> In case of a bulk insert, the â'FOR INSERTâ' trigger fires for each recod or
> only once?
> Thanks,
>

Insert trigger for bulk insert

In case of a bulk insert, the “FOR INSERT” trigger fires for each recod or only once?

Thanks,

Once for each batch. Here's the specific text from Books Online

"Triggers are fired once for each batch in the bulk copy operation. The inserted table passed to the trigger contains all of the rows inserted by the batch."

Note that, by default, the triggers do not fire for bulk operations, you must specify the FIRE_TRIGGERS option in order to get triggers to fire for bulk operations.

|||

This option may have issues with performance if you enable during the bulk load operaton during the otherside of triggers, refer to the books online about Controlling trigger execution when bulk importing data.

HTH

Insert trigger for bulk insert

In case of a bulk insert, the "FOR INSERT" trigger fires for each recod or only once?

Thanks,

(FIRE_TRIGGERS
Specifies that any insert triggers defined on the destination table execute during the bulk-import operation. If triggers are defined for INSERT operations on the target table, they are fired for every completed batch.

If FIRE_TRIGGERS is not specified, no insert triggers execute.

For more information, see Controlling Trigger Execution When Bulk Importing Data. )

What you are looking for is in the BOL(books online). Hope this helps.

http://msdn2.microsoft.com/en-us/library/ms188365.aspx

sql

Insert trigger for bulk insert

In case of a bulk insert, the “FOR INSERT” trigger fires for each recod
or
only once?
Thanks,Only once, and ALL of the rows are in the inserted table.
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
You can't help someone get up a hill without getting a little closer to the
top yourself.
- H. Norman Schwarzkopf
"JIM.H." <JIMH@.discussions.microsoft.com> wrote in message
news:B90E6B36-CA4C-49C0-B4C2-268CA0A241A7@.microsoft.com...
> In case of a bulk insert, the "FOR INSERT" trigger fires for each recod or
> only once?
> Thanks,
>|||To add to Arnie's response, the trigger is fired one for each batch of
records and only if FIRE_TRIGGERS is specified.
Hope this helps.
Dan Guzman
SQL Server MVP
"JIM.H." <JIMH@.discussions.microsoft.com> wrote in message
news:B90E6B36-CA4C-49C0-B4C2-268CA0A241A7@.microsoft.com...
> In case of a bulk insert, the “FOR INSERT” trigger fires for each reco
d or
> only once?
> Thanks,
>|||Hi Jim
The BULK INSERT statement has a FIRE_TRIGGERS option and BCP has it as a
hint, to make INSERT triggers fire. See Books Online for more.
John
"JIM.H." wrote:

> In case of a bulk insert, the “FOR INSERT” trigger fires for each reco
d or
> only once?
> Thanks,
>