var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Need a trigger based on a row
I need to create a trigger to update a FLAG column by row modification. The table likes,
If "a" in Col1 is changed, the "0" in same row (First row) should be changed to '1'. Other FLAG values should not be changed. The same rule for other row.
Anyhelp will be approciated.
Thanks a lot
If col1 is a primary key, this is relatively easy. If you don't have a primary key, I don't know how to do it. Can you "fill in the blanks" a bit on your requirements?
Col1 doesn't have to be a primary key, but you do need a primary key. Put this in your trigger:
set FLAG = 1
inner join Deleted on YourTable.PrimaryKey = Deleted.PrimaryKey
where YourTable.Col1 <> Deleted.Col1
So what happens when the code that launches the trigger is something like:
All of the rows except for one change. Without a PK, things get ugly really fast from a SQL perspective, and I'd guess that the business rules would go berzerk!
UPDATE yourtable SET col1 = 'a'
I think that is what he would want. All of the rows except one were modified, so set the flags on all but one record.
Originally Posted by Pat Phelan
But yes, as I mentioned in my post, he is going to need a primary key on the table.