title: Inserting 0 in sql server by default
body: <p>I want to return the identity element from the table and use it further in the stored procedure, but I always get value as 0.</p>
  
  <p>When I execute this, I get the actual value</p>
  
  <p><code>dbo.TEMPP</code>:</p>
  
  <pre><code>DECLARE @OutputTbl TABLE (ID INT)
  
  INSERT INTO Table(Name) 
  OUTPUT Inserted.HId INTO @OutputTbl(ID) 
  VALUES ('hello')
  
  SELECT ID 
  FROM @OutputTbl
  </code></pre>
  
  <p>But, when I run this code, it inserts 0 into my table</p>
  
  <pre><code>declare @id int;
  exec @id = TEMPP
  
  insert into Table2(Name, sId) 
  values ('hi', @id)
  </code></pre>
  
  <p>Can anyone please suggest?</p>