In your trigger you only updated the row with ID of 1 ! So what about other conditions ?
You can access inserted or deleted rows from the
inserted
and
deleted
tables.
So have look at here :
http://msdn.microsoft.com/en-us/library/aa214435%28v=sql.80%29.aspx[
^]
Another thing is that you don't want constant dates in your trigger, if so it's not necessary to have a trigger !
So your trigger can be like this :
create trigger emp_trigger on emp
after insert
as
begin
declare @todate date
declare @fromdate Date
declare @dt Date
Set @todate='2011-12-01'
set @fromdate='2011-12-06'
update emp set status= 'expired' where Id in (select ID from inserted i where not i.dt between @fromdate and @todate )
update emp set status= 'not expired' where Id in (select ID from inserted i where i.dt between @fromdate and @todate )
End
In this trigger its assumed that there is a
dt
field in your
emp
table and it decides on that field that what should be in
status
field.
Hope it helps.