title: SQL procedure - changing value of table column based on count on other table
body: <p>I have two tables, <code>property</code> and <code>component</code>. <code>component.id_property = property.id</code>. </p>
  
  <p>I'm trying to create a procedure, which counts components on selected property and if there are no components for selected property, it change <code>property.id_state</code> to 1.  </p>
  
  <pre><code>create PROCEDURE property_statement_change AS
  BEGIN
  declare @value int;
  
  select 
      @value = count(c.value)
  from
      component c
  where
      c.id_property = 1
  group by c.id_property
  
  IF (@value = 0)
    UPDATE property
    SET id_state = 1
    WHERE property.id = 1
  END
  </code></pre>
  
  <p>If I execute stored produre, it doesn't change anything, but select and also update works right. What I'm doing wrong? </p>