本文介绍了Sql server存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! Emp_No,In_Time_Punch数据类型datetime,Out_Time_Punch类型日期时间,小时,状态,备注,W_Days,Att_Date,正常时间,正常退出时间 我想要存储过程 显示工作小时数Hrs = Out_Time_Punch-In_Time_Punch ,数据类型为datetime 我还希望存储过程显示备注,如果让In_Time_Punch为空或空为FORGOT IN TIME PUNCH 我尝试了什么: 我试过搜索google我有试过很多公式却失败了 创建程序usp_EmployeeAttendance ( @Emp_No NVARCHAR(50), @In_Time_Punch datetime, @Out_Time_Punch datetime, @Remarks NVARCHAR(50),@ Status varchar(10), @Att_Date date,@ Hrs nchar(10),@ W_Days int ) AS BEGIN IF(@In_Time_Punch> '7:25:00') BEGIN set @Remarks ='LC' END ELSE IF(@In_Time_Punch ='') BEGIN set @Remarks ='IN PUNCH FORGET' IF(@In_Time_Punch< '16:35:00') BEGIN 设置@Remarks ='EL' 结束 ELSE IF(@Out_Time_Punch ='') BEGIN 设置@Remarks ='OUT PUNCH FORGET' END END END 解决方案 Emp_No,In_Time_Punch data type datetime, Out_Time_Punch type datetime,Hrs,Status,Remarks,W_Days,Att_Date,Normal in Time,Normal Out TimeI want stored procedureto show total hours worked Hrs=Out_Time_Punch-In_Time_Punchwith datatype datetimealso I want stored procedure to show remarks if lets In_Time_Punch is empty or null that FORGOT IN TIME PUNCHWhat I have tried:I tried searching google I have tried many formulas but failedCREATE PROCEDURE usp_EmployeeAttendance ( @Emp_No NVARCHAR(50), @In_Time_Punch datetime, @Out_Time_Punch datetime,@Remarks NVARCHAR(50),@Status varchar(10), @Att_Date date,@Hrs nchar(10),@W_Days int )ASBEGINIF(@In_Time_Punch >'7:25:00') BEGIN set @Remarks = 'LC' ENDELSE IF(@In_Time_Punch ='') BEGIN set @Remarks = 'IN PUNCH FORGET' IF (@In_Time_Punch <'16:35:00') BEGIN set @Remarks = 'EL' ENDELSE IF(@Out_Time_Punch ='') BEGIN set @Remarks = 'OUT PUNCH FORGET'ENDENDEND 解决方案 这篇关于Sql server存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
06-18 20:10