fun_sal_operation_emplist

CREATE function fun_sal_operation_emplist(@perno as nvarchar(2))

returns @empList table(empno nvarchar(20))

as
begin

declare @sn_no nvarchar(10)
declare @from_date datetime
declare @end_date datetime

set @sn_no = @perno

select top 1 @from_date=from_date, @end_date= end_date from Sal_period where sn_no = @sn_no

 insert into @empList select distinct empno from hrempm
where ( (duty_flag = 'Y' or    Q_date >@end_date) and arr_date<@from_date)
 or  (arr_date >=@from_date and arr_date <=@end_date)
   or  (q_date >=@from_date and q_date <=@end_date)

 return
end

 

posted @ 2008-09-18 16:38  XGU_Winner  阅读(147)  评论(0编辑  收藏  举报