title: Return last inserted ID without using a second query
body: <p>I'm working on an ASP.NET project (C#) with SQL Server 2008.</p>
  
  <p>When I insert a row into a table in the database, I would like to get the last inserted ID, which is the table's <strong>IDENTITY</strong> (Auto Incremented).</p>
  
  <p>I do not wish to use another query, and do something like...</p>
  
  <pre><code>SELECT MAX(ID) FROM USERS;
  </code></pre>
  
  <p>Because - even though it's only one query - it feels lame...</p>
  
  <p>When I insert something I usually use <strong>ExecuteNonQuery()</strong>, which returns the number of affected rows.</p>
  
  <pre><code>int y = Command.ExecuteNonQuery();
  </code></pre>
  
  <p>Isn't there a way to return the <strong>last inserted ID</strong> without using another query?</p>