title: Update Trigger For Multiple Rows
body: <p>I am trying to Insert data in a table named <code>"Candidate_Post_Info_Table_ChangeLogs"</code> whenever a record is updated in another table named <code>"Candidate_Personal_Info_Table"</code>. my code works fine whenever a single record is updated but when i try to updated multiple rows it gives error: </p>
  
  <p><strong>"Sub query returned more then 1 value".</strong> </p>
  
  <p>Following is my code : </p>
  
  <pre><code>ALTER TRIGGER [dbo].[Candidate_PostInfo_UPDATE]
     ON [dbo].[Candidate_Post_Info_Table]
  AFTER UPDATE
  AS
  BEGIN
     IF @@ROWCOUNT = 0
     RETURN
  
         DECLARE @Candidate_Post_ID int
         DECLARE @Candidate_ID varchar(50)
         DECLARE @Action VARCHAR(50)
         DECLARE @OldValue VARCHAR(MAX)
         DECLARE @NewValue VARCHAR(MAX)
         DECLARE @Admin_id int
  
         IF UPDATE(Verified)
         BEGIN
              SET @Action = 'Changed Verification Status'
              SET @Candidate_Post_ID = (Select ID From inserted)
              SET @Candidate_ID = (Select Identity_Number from inserted)
                SET @NewValue = (Select Verified From inserted)
                SET @OldValue = (Select Verified From deleted)
                IF(@NewValue != @OldValue)
                BEGIN
                INSERT INTO  Candidate_Post_Info_Table_ChangeLogs(Candidate_Post_ID, Candidate_ID,  Change_DateTime, action, NewValue, OldValue, Admin_ID)
                  VALUES(@Candidate_Post_ID, @Candidate_ID, GETDATE(), @Action,  @NewValue, @OldValue, '1')
                  END
         END
  
  END
  </code></pre>
  
  <p>i have searched stack overflow for this issue but couldn't get any related answer specific to this scenario.</p>