sql server - MSSQL After Update Trigger: Multi Row Stored Prc -


i've written stored procedure invoke on row updates.

it this:

create procedure [tracechange]     @id uniqueidentifier, begin     /*do inserts, updates, etc*/ end 

now create trigger table, works fine single row update:

create trigger t1_traceinsert    on t1    after update  begin     set nocount on;     declare @id uniqueidentifier     exec tracechange @id end 

this works fine - single row. how rewrite execute on multi row updates? afaik not great approach use cursor within such triggers.

thanks!

there 2 options:

1) process data in while loop - data inserted table, , execute sp x times - 1 per row.

2) rewrite sp (or create new one) accepts table input parameter. process rows in 1 go if possible. depends on code of sp. so, in trigger, execute sp , pass predefined table based on inserted table

see https://msdn.microsoft.com/en-au/library/bb510489.aspx example.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -