title: SQL Server Triggers Update
body: <p>I have tables Student and Order. When I change the Student ID in the Student table I want the referencing rows in Order to be updated accordingly. I am using triggers. It is not working.</p>
  
  <pre><code>create TRIGGER Update_Student
  ON dbo.Student
  AFTER UPDATE
  AS
  BEGIN
     Declare @oldID int, @newID int
     Select @oldID = d.StudentID, @newID = i.StudentID
     from deleted d, inserted i
     Update Orders 
     set StudentID=@newID where StudentID=@oldID 
  END
  </code></pre>