Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 how to implement a Multirow insert trigger?

Author  Topic 

tpcolson
Starting Member

5 Posts

Posted - 2011-07-05 : 16:08:59
I have the following trigger:
Create trigger [dbo].[new_Location]
on [dbo].[TBL_LOCATIONS]
for insert
as
insert into dbo.tbl_Events ( Event_Id , Location_Id )
SELECT NewID(), Inserted.Location_Id
FROM Inserted

Which works fine on single-record inserts, however, on multiple row inserts to tbl_Events (batch load) the trigger doesn't fire. How can I modify it to work for multiple record inserts?

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-07-05 : 16:17:51
Should work for ,ulti row inserts - what happens when you try?

Could be the batch load isn't firing the trigger - nothing to do with the trigger. How are you doing this and is there an option to fire triggers?

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2011-07-05 : 16:48:05
Also asked here: http://www.sqlservercentral.com/Forums/Topic1136799-391-1.aspx

--
Gail Shaw
SQL Server MVP
Go to Top of Page
   

- Advertisement -