June 16, 2009 at 11:40 pm
tables:
--------------
emp_att_tab(emp_id,in_time,att_date,shift_id,lunch_out_time,lunch_in_time,id)
shift_mas_tab(shift_id,lunch_start_date)
wht ever we inserted lunch start time in shift mas_tab,when we trying to update the attendance tab while entering the lunch out time shouldbe
greater than lunch_starttime and update the lunch outtime in attendance tab
i tried here the outtime is not updating in attendance table
create trigger lunctout_time on emp_att_tab
instead of update
as
begin
declare @b-2 int,@c datetime,@shift_id int
DECLARE @emp_id int,@lunch_start_time datetime,@lunch_out_time datetime,@in_time datetime,@id int
set @b-2=(select shift_id from emp_att_tab where id=(select max(id) from emp_att_tab where emp_id=@emp_id))
set @c=(select lunch_start_time from shift_mas_tab where shift_id=@b )
if (@lunch_out_time>=@c )
begin
update emp_att_tab set lunch_out_time=@lunch_out_time where id=
(select max(id) from emp_att_tab where emp_id=@emp_id)
raiserror ('u should allow here',10,1)
END
else
raiserror ('u should not allow here',10,1)
END
June 17, 2009 at 5:07 am
Please attach sample data together with a more detailed description on what you're trying to achieve.
It's not the "urgent" hint that gives you fast answers, it's the way you'll describe your problem and the data you'll provide.
For details on how to provide sample data please follow the link in my signature.
June 17, 2009 at 5:19 am
sagi (6/16/2009)
write trigger for a table.i.e attendance tablecolumns:emp_id,lunch_out_time,lunch_in_time
suppose lunch_out_time=1pm
in attendance table lunch out time should insert only after 1pm, should not insert before 1 pm
plz send code very urgent thn'ssssssss
duplicate post; same question was asked here:http://www.sqlservercentral.com/Forums/Topic735615-145-1.aspx
you need to provide more information in the other post so we can help.
Lowell
June 17, 2009 at 7:43 am
sagi (6/16/2009)
plz send code very urgent thn'ssssssss
Show us what you have so far. I'm happy to help, but not to do the entire job for you.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply