只是语法错误,跟我写的表名称没有什么关系。
Server: Msg 156, Level 15, State 1, Procedure prcSC0010a, Line 10
Incorrect syntax near the keyword 'select'.
Server: Msg 170, Level 15, State 1, Procedure prcSC0010a, Line 10
Line 10: Incorrect syntax near ')'.
Server: Msg 156, Level 15, State 1, Procedure prcSC0010a, Line 12
Incorrect syntax near the keyword 'else'.
Server: Msg 156, Level 15, State 1, Procedure prcSC0010a, Line 16
Incorrect syntax near the keyword 'end'.

解决方案 »

  1.   

    CREATE PROCEDURE prcSC0010a
         @qjmc char(50),
         @qjjg float,
         @qjgg char(30), 
         @qjsl int, 
         @qjdw char(10),
         @qjhwh char(10)  
    AS
    begin
      if exist(select * from ck where mc=@qjmc) 
        update ck set sl=sl+@qjsl,jg=(jg*sl+@qjsl*@qjjg)/(sl+@qjsl) where mc=@qjmc
      else
      begin
        insert into kc
        values(@qjmc,@qjsl,@qjjg,@qjgg,@qjdw,@qjhwh)
      end
    end
    GO
      

  2.   

    if exist(select * from kc where (mc=@qjmc)) 改为
    if exists(select * from kc where (mc=@qjmc))
      

  3.   

    CREATE PROCEDURE prcSC0010a
         @qjmc char(50),
         @qjjg float,
         @qjgg char(30), 
         @qjsl int, 
         @qjdw char(10),
         @qjhwh char(10)  
    AS
    begin
      if exists(select * from kc where (mc=@qjmc)) 
        update kc set sl=sl+@qjsl,jg=(jg*sl+@qjsl*@qjjg)/(sl+@qjsl) where mc=@qjmc
      else
        insert into kc values(@qjmc,@qjsl,@qjjg,@qjgg,@qjdw,@qjhwh)
    end
    GO