Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trigger firing question

Status
Not open for further replies.

DeveloperJr

Programmer
Mar 10, 2007
25
US
Hey guys,

I am going blank on this one. When we insert into a table from a select statment (more than one record) if there is a trigger on that table, would it be fired for each record (one by one) or the whole insert will fire the trigger once?
 
Once.
You can get the records inserted in the trigger on this way:
Code:
select ... from INSERTED
 
Absolutely it will fire the whole set of records at once. If your code does not acount for multiple record inserts, it will create problems for you later on. And do not use a cursor to account for multiple records. Cursors should especially be avoided in triggers.

Questions about posting. See faq183-874
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top