title: SQL Server : After Insert Trigger for update another Table
body: <p>I wrote this trigger to insert data into another table after data insert into the <code>CHECKINOUT</code> table.</p>
  
  <p>But it doesn't insert data into the <code>Att_process</code> table. No errors is showing up in SQL Server. Can you help me to figure this out problem?</p>
  
  <pre><code>SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  
  CREATE TRIGGER [dbo].[trgAfterInsert] ON [dbo].[CHECKINOUT]
  AFTER  INSERT 
  AS
       DECLARE @uid INT;
       DECLARE @checkin DATETIME;
  
       SELECT @uid = i.USERID
       FROM [CHECKINOUT] i;
  
       SELECT @checkin = i.CHECKTIME
       FROM [CHECKINOUT] i;
  
       IF(DATEPART(HOUR, @checkin) &lt; 12)
       BEGIN
          INSERT INTO Att_process (USERID, checkin_time)
          VALUES (@uid, @checkin);
       END;
       ELSE
       BEGIN
           INSERT INTO Att_process (USERID, checkout_time)
           VALUES (@uid, @checkin);
       END;
  </code></pre>