title: SQL Server : create trigger to replace old value to new value on another table
body: <p>I am using SQL Server 2008. I want to create a trigger for update which will fire on update of user table. </p>
  
  <p>Trigger functionality: replace <code>user_tbl</code> updated mobile number to <code>user_work_tbl</code>. </p>
  
  <pre><code>CREATE TRIGGER [dbo].[tr_User_Modified]
  ON [dbo].[user_tbl]
  AFTER UPDATE
  AS BEGIN
      SET NOCOUNT ON;
      DECLARE @MobileNo varchar(11)
  
      IF UPDATE (mobile_no) 
      BEGIN
          DECLARE @MobileNo VARCHAR(50)
  
          SELECT @MobileNo = mobile_no 
          FROM [dbo].user_tbl
  
          UPDATE [dbo].[user_work_tbl]
          SET mobile_no = @MobileNo 
          WHERE [dbo].[user_work_tbl].mobile_no = @oldMobileNo // here I have a problem
      END 
  END;
  </code></pre>
  
  <p>In the comment "here I have a problem" I need a mobile number which exists in <code>user_tbl</code> before update so that the only row of <code>user_work_tbl</code> gets updated.</p>
  
  <p>Any suggestions to do this are also accepted.</p>
  
  <p>Thanks for your all response</p>