插入时为null
declare @DepartmentId integer
set @DepartmentId=(select DepartmentId from Employee where EmployeeId=@EmployeeId)
declare @baseSalary integer
set @baseSalary=(select baseSalary from Department where DepartmentId=@DepartmentId)
declare @late integer
set @late=(select late from Department where DepartmentId=@DepartmentId)
declare @early integer
set @early=(select early from Department where DepartmentId=@DepartmentId)
declare @absence integer
set @absence= (select absence from Department where DepartmentId=@DepartmentId)
declare @overtime integer
set @overtime=(select overtime from Department where DepartmentId=@EmployeeId)
declare @Account integer
set @Account=@baseSalary-@late*@lateRecord-@early*@earlyRecord-@absence*@AbsenceRecord+@overtime*@overtimeRecord
在执行插入时显示@Account为null....
------解决方案--------------------没有环境,所以只能你自己print/select出来了
------解决方案-----------------------TRY
DECLARE
@DepartmentId INTEGER ,
@baseSalary INTEGER ,
@late INTEGER ,
@early INTEGER ,
@absence INTEGER ,
@overtime INTEGER ,
@Account INTEGER
SELECT
@DepartmentId=DepartmentId, @baseSalary=baseSalary, @late=late,
@early=early, @absence=absence, @overtime=overtime,
@Account=baseSalary-@late*@lateRecord-@early*@earlyRecord-@absence*@AbsenceRecord+@overtime*@overtimeRecord
FROM
Employee AS a
INNER JOIN Department AS b ON a.EmployeeId=b.EmployeeId
WHERE
a.EmployeeId=@EmployeeId