troubleshooting Question

TRIGGER on newly inserted rows only in SQL Server 2005

Avatar of charb0y
charb0y asked on
Microsoft SQL ServerMicrosoft Development
3 Comments1 Solution1974 ViewsLast Modified:
How does the trigger fire?  I'm basically after an efficient way to update on a BULK INSERT in SQL Server 2005

i'm doing a BULK INSERT and want to update  the new rows only after the INSERT.

As the table gets larger and larger, i do not want the conditional UPDATE to query the whole destination table of tblCustomer  -  I only want to query the newly inserted rows.

CREATE TRIGGER triggerA ON tblCustomer AFTER INSERT AS
UPDATE tblCustomer
SET xflag = 1
FROM tblCustomer, tblAddress
WHERE tblCustomer.customerID  = tblAddress.customerID

This trigger runs across the whole of tblCustomers

Now the questions i have are
1.  does the bulk insert complete on all rows, before the trigger is fired
2.  how do i only run the UPDATE query against the new rows


Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros