title: How do I use an INSERT statement's OUTPUT clause to get the identity value?
body: <p>If I have an insert statement such as:</p>
  
  <pre><code>INSERT INTO MyTable
  (  
    Name,
    Address,
    PhoneNo
  )
  VALUES
  (
    'Yatrix',
     '1234 Address Stuff',
     '1112223333'
  )
  </code></pre>
  
  <p>How do I set <code>@var INT</code> to the new row's identity value (called <code>Id</code>) using the OUTPUT clause? I've seen samples of putting INSERTED.Name into table variables, for example, but I can't get it into a non-table variable. </p>
  
  <p>I've tried <code>OUPUT INSERTED.Id AS @var</code>, <code>SET @var = INSERTED.Id</code>, but neither have worked.</p>