SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Trigger on update
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Pete_N
Posting Yak Master

177 Posts

Posted - 09/26/2013 :  10:04:33  Show Profile  Reply with Quote
I have a table that is updated from an external application. I have tried writing a simple update trigger but the problem is that the external application updates x number of records in on hit. As i understand it , a trigger work on the last record from inserted. Is there a way around this ?

James K
Flowing Fount of Yak Knowledge

3742 Posts

Posted - 09/26/2013 :  11:10:39  Show Profile  Reply with Quote
A trigger gets invoked once per DML statement (insert/update/delete), no matter how many rows are affected by that DML statement.

You have access to all the affected rows from within the trigger via two virtual tables: INSERTED and DELETED.

For Insertions, there will be nothing in the DELETED table.
For Deletions, there will be nothing in the INSERTED table.
For Updates, the DELETED table will have the data as it existed before the update, and INSERTED table will have the data as it existed after the update.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000