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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to get ids of updated rows
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

1 Posts

Posted - 04/06/2013 :  12:19:01  Show Profile  Reply with Quote
Hi. I need to write procedure that should be executed by trigger(on update). In procedure I need to know the ids of affected rows(by update). How can I get it? SQL server. Thx

Jeff Moden
Aged Yak Warrior

652 Posts

Posted - 04/07/2013 :  12:20:24  Show Profile  Reply with Quote
I've not tried them in a trigger before (I try to avoid any heavy lifting in triggers), but you might be able to use Table-Valued Parameters here. Please look for "parameters [SQL Server], table-valued" (without the quotes) in Books Online (press the {f1} key to get there). Then, just populate the Table-Valued Parameter from the INSERTED logical trigger table and use it in the call to the stored procedure. Of course, the stored procedure will need to be modified to use the new Table-Valued Parameter.

--Jeff Moden
RBAR is pronounced "ree-bar" and is a "Modenism" for "Row By Agonizing Row".

First step towards the paradigm shift of writing Set Based code:
"Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

When writing schedules, keep the following in mind:
"If you want it real bad, that's the way you'll likely get it."

Edited by - Jeff Moden on 04/07/2013 12:20:39
Go to Top of Page

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 04/09/2013 :  00:16:24  Show Profile  Reply with Quote
i would prefer doing the processing inline in trigger without need to call another procedure

SQL Server MVP
Go to Top of Page
  Previous Topic Topic Next 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.02 seconds. Powered By: Snitz Forums 2000