如何在使用SQL Job的过程中每月针对雇员添加叶子 [英] How to add leaves Every month against Employee in using SQL Job

查看:66
本文介绍了如何在使用SQL Job的过程中每月针对雇员添加叶子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我创建了一个表tblEmployee(员工详细信息)和tblLeaveDetail(EmpID,LeaveTaken,LeaveRemain).
我需要做一份工作,每个月应在剩下的叶子上增加两天半的时间.如果某人在15日之后的那个月加入,那么只会增加1个请假.

请帮忙.

谢谢
sanjeev

Hello All,

I have created a table tblEmployee(employee detail) and tblLeaveDetail(EmpID,LeaveTaken,LeaveRemain).
I need to make a job by which every month there should be addition of two and half day in there remaining leaves. if a person is joining in that month after 15th then only 1 leave will get added.

please help.

thanks
sanjeev

推荐答案

我看到您的数据库设计有问题.理想情况下,应该在每次需要基于当前日期和月份的值时进行计算,而不是在数据库列中存储剩余休假".

如果您仍然希望继续进行设计,建议您创建一个存储过程以更新休假余额,并从以特定间隔运行的SQL作业中调用该存储过程.如果存储过程在同一时间间隔内多次运行,则您的逻辑仍然可能是错误的,除非您当然采取预防措施以避免多次更新以保持余额.
I see a problem with your database design. Instead of storing ''Remaining leave'' in a database column, you should ideally calculate it every time the value is required based on the current date and month.

If you still wish to proceed with your design, I would suggest you create a stored procedure that updates the leave balance and call this stored procedure from an SQL job that runs on specific intervals. Your logic can still be wrong if the stored procedure is run more than once during the same interval, unless of course you take precautions to avoid multiple updates to leave balances.


这篇关于如何在使用SQL Job的过程中每月针对雇员添加叶子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆