Solved

Multiple select results in trigger

Posted on 2013-01-13
3
672 Views
Last Modified: 2013-01-13
I am using sql-server 2005.

I am writing a trigger for table A.

When table A is updated, i wish to record in table Y data from rows in table B which reference the primary key for table A. (i.e.: there is a column in table b which has a foreign key which references table A. I need data from all the rows which have this foreign key in it)

Is this possible (and how would I do it)?

Can I write a loop within the trigger which runs for each row of a select query?
0
Comment
Question by:rdun25
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 12

Accepted Solution

by:
Saurabh Bhadauria earned 500 total points
ID: 38773302
0
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 38773331
yes you can.

but what is your eaxtact requirment ?

You want to update table Y riws from table B with Ref in Table A.
can you give some sample data so that we can help you in creatinmg trigger
trigger can be wriiten like this

CREATE TRIGGER Whatever ON TableName AFTER UPDATE
AS
BEGIN
    IF UPDATE(B)
    BEGIN
        /* Update column C here */
    END
END
0
 

Author Comment

by:rdun25
ID: 38773380
Thanks for your help, those are great articles, solved my problem.
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently I was talking with Tim Sharp, one of my colleagues from our Technical Account Manager team about MongoDB’s scalability. While doing some quick training with some of the Percona team, Tim brought something to my attention...
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question