heisenbug29
heisenbug29

Reputation: 165

Identify inserted row values to run stored procedure

I have a table Table_A and a stored procedure Calculate_B that does some calculations on the data in Table_A and update Table_B accordingly.

How can I run the stored procedure Calculate_B only on the newly inserted rows in Table_A and insert the new rows accordingly in Table_B

CREATE PROCEDURE Calculate_B
AS
----some sql statements-----
SELECT * FROM Table_A;

Edit1 : The inserts are made from a windows application which uses entity framework to add data in the database

Upvotes: 0

Views: 386

Answers (1)

Yoni Ziv
Yoni Ziv

Reputation: 176

You could add another column to your table of type Bit and call it digestedFlag (or anything else you like)

Then, edit your Calculate_B Procedure and make it only update rows with digestedFlag=0. Once the calculation is done (Or during) - update all your rows digestedFlag to be 1 (So they won't be calculated on next run)

Upvotes: 1

Related Questions