SQL Server Database Error: 在关键字 'then' 附近有语法错误,请问是什么错误

useincome_clgocreatetriggerBudgetInsertonM_Budget_Dayafterinsertasbegindeclare@Budget... use income_cl
go
create trigger BudgetInsert
on M_Budget_Day
after insert
as
begin
declare @BudgetYear int ,@ItemGroup varchar(10),@company varchar(10),@month int ,@count decimal(18,4)
set @month = (select month from inserted )
set @BudgetYear = (select budgetYear from inserted)
set @ItemGroup = (select ItemGroup from inserted)
set @company = (select company from inserted)
set @count = (select day1+day2+day3+day4+day5+day6+day7+day8+day9+day10+day11+day12+day13+day14+day15+day16+day17+day18+day19+day20+day21+day22+day23+day24+day25+day26+day27+day28+day29+day30+day31 from inserted);
if @month = 1 then
update M_Budget set Month1 = @count where BudgetYear = @BudgetYear and Company = @company and ItemGroup = @ItemGroup
else if @month = 2 then
update M_Budget set Month2 = @count where BudgetYear = @BudgetYear and Company = @company and ItemGroup = @ItemGroup
else if @month = 3 then
update M_Budget set Month3 = @count where BudgetYear = @BudgetYear and Company = @company and ItemGroup = @ItemGroup
else if @month = 4 then
update M_Budget set Month4 = @count where BudgetYear = @BudgetYear and Company = @company and ItemGroup = @ItemGroup
else if @month = 5 then
update M_Budget set Month5 = @count where BudgetYear = @BudgetYear and Company = @company and ItemGroup = @ItemGroup
else if @month = 6 then
update M_Budget set Month6 = @count where BudgetYear = @BudgetYear and Company = @company and ItemGroup = @ItemGroup
else if @month = 7 then
update M_Budget set Month7 = @count where BudgetYear = @BudgetYear and Company = @company and ItemGroup = @ItemGroup
else if @month = 8 then
update M_Budget set Month8 = @count where BudgetYear = @BudgetYear and Company = @company and ItemGroup = @ItemGroup
else if @month = 9 then
update M_Budget set Month9 = @count where BudgetYear = @BudgetYear and Company = @company and ItemGroup = @ItemGroup
else if @month = 10 then
update M_Budget set Month10 = @count where BudgetYear = @BudgetYear and Company = @company and ItemGroup = @ItemGroup
else if @month = 11 then
update M_Budget set Month11 = @count where BudgetYear = @BudgetYear and Company = @company and ItemGroup = @ItemGroup
else if @month = 12 then
update M_Budget set Month12 = @count where BudgetYear = @BudgetYear and Company = @company and ItemGroup = @ItemGroup
end if
end
展开
 我来答
你好师姐
推荐于2017-07-24 · TA获得超过123个赞
知道小有建树答主
回答量:177
采纳率:0%
帮助的人:140万
展开全部
删除then ,语法如下:

if (条件)
begin
语法
end
else
begin
语法2
end
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式