[SQL] Trigger assigns the value of the auto-increment ID to another field

ALTER TRIGGER test_Rate  ON dbo.tRate
FOR insert
AS      
declare  @errno   int,  @errmsg  varchar(255)  
 begin       
UPDATE dbo.tRate
SET vcUpdaterId=Inserted.iAutoId
FROM  dbo.tRate, inserted
WHERE dbo.tRate.iAutoId= inserted .iAutoId  
  end      
return  
error:  
    raiserror @errno @errmsg  
    rollback transaction

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324540980&siteId=291194637