December 29, 2009 at 12:43 am
Dear All,
I am writing a trigger. I have a table with 10 columns.
There is a column RowId (PK).
There is another column "Enabled". User can set it to 1 or 0.
I want to create a trigger which should fire after udpate of "Enabled" filed from 1 to 0 or vice versa. When the value of "Enabled" change trigger should add a new record into another table.
My problem is that I am not able to find which row has been updated. In other words, how will I found the RowId of the row which has been updated.
Thanks and regards,
Sumit
December 29, 2009 at 1:23 am
You can get the RowID by sing the 'inserted'/updated table. This table is accessible in triggers during an Insert, Update and Delete operation.
The update scenario is something like this:
- The old data is written in deleted table.
- The new data is written in Inserted table.
Read about 'inserted tables' and 'deleted tables' in BOL for more details.
-Vikas Bindra
December 29, 2009 at 9:07 am
This article[/url] gives an introduction to writing triggers.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply