For changing the field value from ¡®Yes¡¯ no ¡®No¡¯ you can use the trigger (for update).
Mani is correct. Here is an example of the update trigger.
e.g.
create trigger _tr on InputData
for update
as
if @@rowcount=0 return;
update tb
set calculated = 'no'
from InputData tb join Inserted i on tb.[pk] = i.[pk]
where tb.calculated='yes'
go
Hi!
You can directly include "Calculated ='no'" statement within the your update command itself only, based on the condition only. otherwise all the records will get updated.
eg:
Update InsertData
Set
Column1 = value1,
Column2 = value2,
...,
Calculated ='no'
WHERE <Condition>
I hope it'll solve your problem and please let me know if I'm wrong.
Thanks & Regards,
Kiran.Y
1. Yes. Sql2k does support trigger.
2. Inserted (or deleted) table is a special memory-resident table that can only be accessed in a trigger.
3. Trigger is just another object in sqlserver, similar to stored procedure.
4. Yes. Trigger is an event based procedure. It's tied to an event of the table (insert/update/delete).
5. This line tells the system to go ahead and exit and skip the rest of the code within the trigger because there is no row affected by the event.
http://msdn2.microsoft.com/en-us/library/aa258254(SQL.80).aspx
You can use IF UPDATE() clause inside the trigger to check.
e.g.
IF UPDATE(calculated)
PRINT ('column [calculated] is modified')
create trigger removeoldOutputData on InputData
for update
as
if @@rowcount=0 return;
delete from OutputData
where primarykey in (select primarykey from Inserted)
select
field1, field2, field3, ...., fieldn
into #inputdataforcalculations
from InputData
where primarykey not in (select primarykey from OutputData)
--more code follows to perform calculations on those records that were put into --#inputdataforcalculations