title: Sql Server - How to get last id inserted into table
body: <p>I'm trying to get the last id inserted into a table.
  I was using </p>
  
  <pre><code>SELECT IDENT_CURRENT('TABLE')
  </code></pre>
  
  <p>But the problem is that it doesn't return the last inserted id, it returns the max inserted id.</p>
  
  <p>For example, if i do:</p>
  
  <pre><code>INSERT INTO 'TABLA' (ID) VALUES (100)
  
  SELECT IDENT_CURRENT('TABLE') returns 100
  </code></pre>
  
  <p>but then if i do</p>
  
  <pre><code>INSERT INTO 'TABLA' (ID) VALUES (50)
  
  SELECT IDENT_CURRENT('TABLE') returns 100
  </code></pre>
  
  <p>and I want to get 50</p>
  
  <p>I need the ID of a specific table, and I generate the id dinamically, so it's not an identity
  How can i do it?</p>