title: Setting variable SQL Procedure
body: <p>I am working on a database that contains customers, products, timesheets, etc for a store. The question I am working on involves creating a procedure that will change an "on/off" column to off (the product is available (1) by default, and this procedure turns it to 0) I have writen the procedure fine:</p>
  
  <pre><code>create proc p_fudgemart_deactivate_product 
  (
      @product_id int
  )
  as
  begin
  update fudgemart_products
  set product_is_active = 0
  where product_id = @product_id
  end
  </code></pre>
  
  <p>but the issue then comes when we are given a product NAME, and need to write a select statement to change that product to unavailable. I know that this requires the use of a variable, but I cannot figure out how to set the variable to the product id of that product. I was thinking something along the lines of:</p>
  
  <pre><code>Declare @prod_name_id int
      set @prod_name_id= (select product_id from fudgemart_products
      where product_name = 'Slot Screwdriver')
      execute p_fudgemart_deactivate_product product_id @prod_name_id
  </code></pre>
  
  <p>Am I able to use a select in my variable declaration like this?</p>