码迷,mamicode.com
首页 > 数据库 > 详细

Sql server抛出异常(RAISERROR)

时间:2018-04-18 11:39:55      阅读:353      评论:0      收藏:0      [点我收藏+]

标签:end   state   roc   %s   null   res   BMI   declare   char   

create PROCEDURE [dbo].[spTASKS_ASSIGNED_Update]
    (
      @ID UNIQUEIDENTIFIER OUTPUT ,
      @MODIFIED_USER_ID UNIQUEIDENTIFIER = NULL ,
      @ASSIGNED_USER_ID UNIQUEIDENTIFIER = NULL             
    )
AS
    DECLARE @ASSIGNED_USER_NAME NVARCHAR(100);
    SELECT  @ASSIGNED_USER_NAME = ASSIGNED_TO_NAME
    FROM    dbo.vwTASKS
    WHERE   ID = @ID;
    IF @ASSIGNED_USER_NAME IS NULL
        BEGIN
            UPDATE  [TASKS]
            SET     [MODIFIED_USER_ID] = @MODIFIED_USER_ID ,
                    [DATE_MODIFIED] = GETDATE() ,
                    [ASSIGNED_USER_ID] = @ASSIGNED_USER_ID ,
                    STATUS = ‘In progress‘
            WHERE   [ID] = @ID;   
        END;
    ELSE
        BEGIN
            RAISERROR    
  
  (N‘Submit failed, this task is assigned to %s!‘,    
  16, -- Severity.    
  1, -- State.  
  @ASSIGNED_USER_NAME
  );      
        END;           
        
              
    
        

  

Sql server抛出异常(RAISERROR)

标签:end   state   roc   %s   null   res   BMI   declare   char   

原文地址:https://www.cnblogs.com/kangjing/p/8872562.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!