title: How to update a table using stored procedures in SQL Server
body: <p>I have created a table in SQL Server called "Employee", and now I want to update the table using a stored procedure. </p>
  
  <p>The table has <code>emp_name</code>, <code>emp_code</code> and <code>status</code> columns. Assume the table has three records: initially, in the stored procedure I want to fetch the last two records using a select statement and I have to the fetched records' <code>status</code> to  'Y'.</p>
  
  <p>I have written a stored procedure, but it's not affecting the original table. Kindly suggest the query for the stored procedure.</p>
  
  <p>Here is the query I have made:</p>
  
  <pre><code>create  procedure updtdemployee As
    select e.Emp_name ,e.Circle 
    from employee e 
    where e.Emp_Code ='2501' or e.Emp_Code='2502'
  
    begin
      update employee set status='Y' where Emp_name = employee.Emp_name
    end
  </code></pre>