图片 上注意那个“应用”按钮是灰色的,表示Sql server企业管理器已经接受这种语法了。太奇怪了

解决方案 »

  1.   

    在JOB(作业)里的script语法检查里, 情况1:
    我写的这个,Insert into TimeLength96163 ( UserID,IPAddress,LoginTime,LogoutTime)后面什么都没有了,可是语法检查是对的。if exists(Select UserID from WorkTable96163 where IPAddress = @chvIPAddress) --查看这个IP有用户登录
    begin
    -- 只有一次登录与登出时间相差10分钟才有效
    --print ''
    Insert into TimeLength96163 ( UserID,IPAddress,LoginTime,LogoutTime) -- select UserID,IPAddress,LoginTime,LogoutTime From WorkTable96163 where IPAddress = @chvIPAddress and datediff(Minute,LoginTime,LogoutTime)>=10 --Insert into TimeLength96163_Backup ( UserID,IPAddress,LoginTime,LogoutTime) select UserID,IPAddress,LoginTime,LogoutTime From WorkTable96163 where IPAddress = @chvIPAddress and datediff(Minute,LoginTime,LogoutTime)>=10 Update  WorkTable96163 set  UserID = @intUserID,LoginTime = Getdate(), LogoutTime = Getdate() where IPAddress = @chvIPAddress

    end  是通不过的
      

  2.   

    CREATE PROCEDURE aa 
    @chvIPAddress int,
    @intUserID int
    As
    if exists(Select UserID from WorkTable96163 where IPAddress = @chvIPAddress) --查看这个IP有用户登录
    begin
    -- 只有一次登录与登出时间相差10分钟才有效
    print ''
    Insert into TimeLength96163 ( UserID,IPAddress,LoginTime,LogoutTime)  select UserID,IPAddress,LoginTime,LogoutTime From WorkTable96163 where IPAddress = @chvIPAddress and datediff(Minute,LoginTime,LogoutTime)>=10 Insert into TimeLength96163_Backup ( UserID,IPAddress,LoginTime,LogoutTime) select UserID,IPAddress,LoginTime,LogoutTime From WorkTable96163 where IPAddress = @chvIPAddress and datediff(Minute,LoginTime,LogoutTime)>=10 Update  WorkTable96163 set  UserID = @intUserID,LoginTime = Getdate(), LogoutTime = Getdate() where IPAddress = @chvIPAddress

    end 是对的呀!
      

  3.   

    CREATE PROCEDURE aa 
    @chvIPAddress int,
    @intUserID int
    As
    if exists(Select UserID from WorkTable96163 where IPAddress = @chvIPAddress) --查看这个IP有用户登录
    begin
    -- 只有一次登录与登出时间相差10分钟才有效
    print ''
    Insert into TimeLength96163 ( UserID,IPAddress,LoginTime,LogoutTime)  select UserID,IPAddress,LoginTime,LogoutTime From WorkTable96163 where IPAddress = @chvIPAddress and datediff(Minute,LoginTime,LogoutTime)>=10 Insert into TimeLength96163_Backup ( UserID,IPAddress,LoginTime,LogoutTime) select UserID,IPAddress,LoginTime,LogoutTime From WorkTable96163 where IPAddress = @chvIPAddress and datediff(Minute,LoginTime,LogoutTime)>=10 Update  WorkTable96163 set  UserID = @intUserID,LoginTime = Getdate(), LogoutTime = Getdate() where IPAddress = @chvIPAddress

    end 
    确实是对的!