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

SQL SERVER 语法问题
create proc tenYuan
@taskID int,
@manID int
as
declare @numebr int
set @numebr=(select COUNT(ID) from dbo.Summit where TaskID=@taskID)
if @numebr=0
begin 
  update dbo.Man set Price=Price where ID=@manID
end
if @numebr=1
begin
  update dbo.Man set Price=Price+10 where ID=@manID
end
if @numebr=2
begin 
  update dbo.Man set Price=Price+10 where ID=@manID
end
if @numebr>=3
begin 
  update 
  (select a.Price from dbo.Man a
  left join
  (select top 3 ManID from dbo.Summit where TaskID=@taskID order by SummitTime) b
  on a.ID=b.ManID)c
  set c.Price=c.Price+10
end







这是为什么错呢。。该怎样修改呢、、、

------解决方案--------------------
SQL code
update a set a.Price=a.Price+10
from  from dbo.Man a
  left join
  (select top 3 ManID from dbo.Summit where TaskID=@taskID order by SummitTime) b
  on a.ID=b.ManID

------解决方案--------------------
SQL code
update a set a.Price=a.Price+10
from dbo.Man a
  left join
  (select top 3 ManID from dbo.Summit where TaskID=@taskID order by SummitTime) b
  on a.ID=b.ManID