SQL触发器未触发

时间:2013-06-28 16:14:36

标签: sql triggers

我更新表格并且触发器不会触发。或者至少它似乎没有在其他表中插入信息。我的代码中可能缺少某些内容吗?

ALTER TRIGGER [dbo].[UpdateUsers]
ON [VLS_TEST].[dbo].[Identifier]
AFTER UPDATE
AS
    DECLARE @Status VARCHAR(4)
    DECLARE @License_Nbr VARCHAR(9)
    DECLARE @Email VARCHAR (100)
    DECLARE @FName VARCHAR(15)
    DECLARE @LName VARCHAR(25)

    SELECT @Status = Status,
           @License_Nbr = License_Nbr,
           @Email = Email,
           @FName = FName,
           @LName = LName
    FROM   VLS_Test.dbo.Identifier

    IF ( @Status = 'LISC'
         AND ( @License_Nbr LIKE '__01%'
                OR @License_Nbr LIKE '__06%' ) )
      BEGIN
          -- SET NOCOUNT ON added to prevent extra result sets from
          -- interfering with SELECT statements.
          SET NOCOUNT ON;

          IF NOT EXISTS (SELECT *
                         FROM   RTT_DEV.dbo.Users
                         WHERE  RTT_DEV.dbo.Users.TerminalOperatorNum = @License_Nbr)
            BEGIN
                INSERT INTO RTT_DEV.dbo.Users
                            (Username,
                             PASSWORD,
                             UserType,
                             TerminalOperatorNum,
                             AdminName,
                             FirstName,
                             LastName)
                VALUES      (@Email,
                             '********',
                             '2',
                             @License_Nbr,
                             'System',
                             @FName,
                             @LName)
            END
      END 

0 个答案:

没有答案