0

我更新了表格并且触发器没有触发。或者至少它似乎没有将信息插入到另一个表中。我的代码中是否可能缺少某些内容?

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 
4

0 回答 0