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
 General SQL Server Forums
 New to SQL Server Programming
 How to get ids of updated rows
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

killme
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

USA
649 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

visakh16
Very Important crosS Applying yaK Herder

India
52325 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
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
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.06 seconds. Powered By: Snitz Forums 2000