bit hasRepeatRecord = NOT EXISTS(SELECT PostId FROM MaterialList WHERE UserId=@UserId AND ClassCode=@ClassCode AND (datediff(day,PostDate,getdate())=0 OR datediff(day,RefreshDate,getdate())=0)
IF ( @PostAction = 0 AND hasRepeatRecord )
beginend错误提示:
Server: Msg 170, Level 15, State 1, Procedure MaterialCreateUpdateDelete, Line 72
Line 72: Incorrect syntax near 'bit'.
Server: Msg 156, Level 15, State 1, Procedure MaterialCreateUpdateDelete, Line 73
Incorrect syntax near the keyword 'IF'.
Server: Msg 170, Level 15, State 1, Procedure MaterialCreateUpdateDelete, Line 73
Line 73: Incorrect syntax near ')'.
Server: Msg 156, Level 15, State 1, Procedure MaterialCreateUpdateDelete, Line 166
Incorrect syntax near the keyword 'END'.

解决方案 »

  1.   

    if NOT EXISTS(SELECT PostId FROM MaterialList WHERE UserId=@UserId AND ClassCode=@ClassCode AND (datediff(day,PostDate,getdate())=0 OR datediff(day,RefreshDate,getdate())=0)
    set hasRepeatRecord=1
    else
    set hasRepeatRecord=0IF ( @PostAction = 0 AND hasRepeatRecord )
    begin
    end
      

  2.   

    IF ( @PostAction = 0 AND  (NOT EXISTS(SELECT PostId FROM MaterialList WHERE UserId=@UserId AND ClassCode=@ClassCode AND (datediff(day,PostDate,getdate())=0 OR datediff(day,RefreshDate,getdate())=0))
     )
    beginend
      

  3.   

    up up up up up up up up