本文介绍了错误:名称“EmpBenefitDeductID”在这种情况下是不允许的。有效表达式是常量,常量表达式和(在某些上下文中)变量。不允许使用列名。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
CREATE PROCEDURE InsertEmployeeBenefitsDeducts
(
@BranchID bigint,
@EmployeeID bigint,
@BenefitDeductionID bigint,
@AffectOnLeave bit,
@Amount decimal(18,4),
@CreatedUserID bigint,
@CreatedDate datetime,
@ModifiedUserID bigint,
@ModifiedDate datetime
)
AS
DECLARE @EmpBenefitDeductID as bigint
SELECT @EmpBenefitDeductID=ISNULL(MAX(EmployeeBenefitsDeducts.EmpBenefitDeductID),0)FROM EmployeeBenefitsDeducts
SET @EmpBenefitDeductID=@EmpBenefitDeductID+1
INSERT INTO EmployeeBenefitsDeducts VALUES
(
EmpBenefitDeductID,
BranchID,
EmployeeID,
BenefitDeductionID,
AffectOnLeave,
Amount,
CreatedUserID,
CreatedDate,
ModifiedUserID,
ModifiedDate
)
VALUES
(
@EmpBenefitDeductID
@BranchID ,
@EmployeeID ,
@BenefitDeductionID ,
@AffectOnLeave ,
@Amount (18,4),
@CreatedUserID ,
@CreatedDate ,
@ModifiedUserID ,
@ModifiedDate
)
SELECT @EmpBenefitDeductID
推荐答案
CREATE PROCEDURE InsertEmployeeBenefitsDeducts
(
@BranchID bigint,
@EmployeeID bigint,
@BenefitDeductionID bigint,
@AffectOnLeave bit,
@Amount decimal(18,4),
@CreatedUserID bigint,
@CreatedDate datetime,
@ModifiedUserID bigint,
@ModifiedDate datetime
)
AS
BEGIN
DECLARE @EmpBenefitDeductID as bigint
SELECT @EmpBenefitDeductID=ISNULL(MAX(EmployeeBenefitsDeducts.EmpBenefitDeductID),0)FROM EmployeeBenefitsDeducts
SET @EmpBenefitDeductID=@EmpBenefitDeductID+1
INSERT INTO EmployeeBenefitsDeducts (EmpBenefitDeductID, BranchID, EmployeeID, BenefitDeductionID, AffectOnLeave, Amount, CreatedUserID, CreatedDate, ModifiedUserID, ModifiedDate)
VALUES (@EmpBenefitDeductID, @BranchID, @EmployeeID , @BenefitDeductionID , @AffectOnLeave , @Amount , @CreatedUserID , @CreatedDate , @ModifiedUserID , @ModifiedDate)
SELECT @EmpBenefitDeductID AS EmpBenefitDeductID
END
这篇关于错误:名称“EmpBenefitDeductID”在这种情况下是不允许的。有效表达式是常量,常量表达式和(在某些上下文中)变量。不允许使用列名。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!