日期:2014-05-18  浏览次数:20529 次

错误
create trigger [lunwendefen] on [dbo].[编写] 
for insert 
as 
declare @论文个人得分 float
declare @论文得分 float 
declare @参加人数 int 
declare @分工 char(50) 
declare @论文编号 char(10) 
set @论文编号=(select 论文编号 from inserted)
set @论文得分=(select 论文得分 from 论文 where 论文.论文编号=@论文编号) 
set @参加人数=(select 参加人数 from 论文 where 论文.论文编号=@论文编号) 
set @分工=( select 分工 from inserted) 
begin
case 
when @参加人数=1 then set @score1=@论文得分
when @参加人数=2 and @分工='参加人1' then set @论文个人得分 = @论文得分*0.7
when @参加人数=2 and @分工='参加人2' then set @论文个人得分 = @论文得分*0.3
when @参加人数=3 and @分工='参加人1' then set @论文个人得分 = @论文得分*0.6
when @参加人数=3 and @分工='参加人2' then set @论文个人得分 = @论文得分*0.3
when @参加人数=3 and @分工='参加人3' then set @论文个人得分 = @论文得分*0.1
when @参加人数=4 and @分工='参加人1' then set @论文个人得分 = @论文得分*0.5
when @参加人数=4 and @分工='参加人2' then set @论文个人得分 = @论文得分*0.3
when @参加人数=4 and @分工='参加人3' then set @论文个人得分 = @论文得分*0.1
when @参加人数=4 and @分工='参加人4' then set @论文个人得分 = @论文得分*0.1
when @参加人数=5 and @分工='参加人1' then set @论文个人得分 = @论文得分*0.5
when @参加人数=5 and @分工='参加人2' then set @论文个人得分 = @论文得分*0.2
when @参加人数=5 and @分工='参加人3' then set @论文个人得分 = @论文得分*0.1
when @参加人数=5 and @分工='参加人4' then set @论文个人得分 = @论文得分*0.1
when @参加人数=5 and @分工='参加人5' then set @论文个人得分 = @论文得分*0.1
when @参加人数=6 and @分工='参加人1' then set @论文个人得分 = @论文得分*0.5
when @参加人数=6 and @分工='参加人2' then set @论文个人得分 = @论文得分*0.15
when @参加人数=6 and @分工='参加人3' then set @论文个人得分 = @论文得分*0.1
when @参加人数=6 and @分工='参加人4' then set @论文个人得分 = @论文得分*0.1
when @参加人数=6 and @分工='参加人5' then set @论文个人得分 = @论文得分*0.05
when @参加人数=6 and @分工='参加人6' then set @论文个人得分 = @论文得分*0.05
end as 论文个人得分
from 编写



消息 156,级别 15,状态 1,过程 lunwendefen,第 14 行
关键字 'case' 附近有语法错误。
消息 156,级别 15,状态 1,过程 lunwendefen,第 16 行
关键字 'when' 附近有语法错误。
消息 156,级别 15,状态 1,过程 lunwendefen,第 17 行
关键字 'when' 附近有语法错误。
消息 156,级别 15,状态 1,过程 lunwendefen,第 18 行
关键字 'when' 附近有语法错误。
消息 156,级别 15,状态 1,过程 lunwendefen,第 19 行
关键字 'when' 附近有语法错误。


------解决方案--------------------
case when是用于:计算条件列表并返回多个可能结果表达式之一。是用来返回结果的。
你这里用于执行代码,当然报错啦。
具体参考:http://msdn.microsoft.com/zh-cn/library/ms181765.aspx
------解决方案--------------------
把case when 改為if 就行了