子查询返回的值多于一个。当子查询跟随在 =、!=、<、<=、>、>= 之后,或子查询用作表达式时,这种情况是
createTRIGGER[dbo].[BudgetDelete]on[dbo].[M_Budget_Day]afterdeleteasbegindeclare@Budg...
create TRIGGER [dbo].[BudgetDelete]
on [dbo].[M_Budget_Day]
after delete
as
begin
declare @BudgetYear int ,@ItemGroup varchar(10),@company varchar(10),@month int ,@count decimal(18,4)
set @month = (select month from deleted )
set @BudgetYear = (select budgetYear from deleted)
set @ItemGroup = (select ItemGroup from deleted)
set @company = (select company from deleted)
set @count = 0;
if @month = 1
update M_Budget set Month1 = @count where BudgetYear = @BudgetYear and Company = @company and ItemGroup = @ItemGroup
else if @month = 2
update M_Budget set Month2 = @count where BudgetYear = @BudgetYear and Company = @company and ItemGroup = @ItemGroup
else if @month = 3
update M_Budget set Month3 = @count where BudgetYear = @BudgetYear and Company = @company and ItemGroup = @ItemGroup
else if @month = 4
update M_Budget set Month4 = @count where BudgetYear = @BudgetYear and Company = @company and ItemGroup = @ItemGroup
else if @month = 5
update M_Budget set Month5 = @count where BudgetYear = @BudgetYear and Company = @company and ItemGroup = @ItemGroup
end
GO
出现错误:
子查询返回的值多于一个。当子查询跟随在 =、!=、<、<=、>、>= 之后,或子查询用作表达式时,这种情况是不允许的。 展开
on [dbo].[M_Budget_Day]
after delete
as
begin
declare @BudgetYear int ,@ItemGroup varchar(10),@company varchar(10),@month int ,@count decimal(18,4)
set @month = (select month from deleted )
set @BudgetYear = (select budgetYear from deleted)
set @ItemGroup = (select ItemGroup from deleted)
set @company = (select company from deleted)
set @count = 0;
if @month = 1
update M_Budget set Month1 = @count where BudgetYear = @BudgetYear and Company = @company and ItemGroup = @ItemGroup
else if @month = 2
update M_Budget set Month2 = @count where BudgetYear = @BudgetYear and Company = @company and ItemGroup = @ItemGroup
else if @month = 3
update M_Budget set Month3 = @count where BudgetYear = @BudgetYear and Company = @company and ItemGroup = @ItemGroup
else if @month = 4
update M_Budget set Month4 = @count where BudgetYear = @BudgetYear and Company = @company and ItemGroup = @ItemGroup
else if @month = 5
update M_Budget set Month5 = @count where BudgetYear = @BudgetYear and Company = @company and ItemGroup = @ItemGroup
end
GO
出现错误:
子查询返回的值多于一个。当子查询跟随在 =、!=、<、<=、>、>= 之后,或子查询用作表达式时,这种情况是不允许的。 展开
2个回答
推荐于2018-05-04
展开全部
set @month = (select month from deleted )
set @BudgetYear = (select budgetYear from deleted)
set @ItemGroup = (select ItemGroup from deleted)
set @company = (select company from deleted)
这4句可能会有问题,加上一个top 1 就不会有错了。
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询