create proc ProcSetOpenMonth(@GcompanyUser varchar(120),@months int)
as
begin
declare @PoorNum int
if exists(select * from Hr_OpenMonth where GcompanyUser=@GcompanyUser)
begin
--if(datediff(d,GstartDate,getdate()))
select @PoorNum=datediff(d,getdate(),dateadd(m,GopenMonth,GstartDate)) from Hr_OpenMonth
if(@PoorNum>=0)
begin
update Hr_OpenMonth set GstartDate=getdate(),GopenMonth=@months+datediff(m,getdate(),dateadd(m,GopenMonth,GstartDate)) where GcompanyUser=@GcompanyUser
end
else
begin
update Hr_OpenMonth set GstartDate=getdate(),GopenMonth=@months where GcompanyUser=@GcompanyUser
end
end
else
begin
insert into Hr_OpenMonth(GcompanyUser,GstartDate,GopenMonth) values(@GcompanyUser,getdate(),@months)
end
end
go
文章来源:
http://www.cnblogs.com/wangdetian168/archive/2008/12/06/1349177.html
posted on 2010-10-11 09:27
sanmao 阅读(86)
评论(0) 编辑 收藏