title: IDENT_CURRENT returns the last identity value but SCOPE_IDENTITY does not
body: <p>I have a SQL Server as backend for an asp.net application. Multiple people might insert data in the same table 'the same time...'.</p>
  
  <p>When I read the solution/answer from this post: <a href="https://stackoverflow.com/questions/567171/scope-identity-vs-ident-current">scope_identity vs ident_current</a></p>
  
  <p>THEN I should not use the <code>Ident_current</code> because I could get the id of the insert of another user.</p>
  
  <p>But using <code>Select Scope_Identity();</code> returns me NULL while the <code>Select IDENT_CURRENT('tableName')</code> returns me the correct id which I checked with SQL Server Management Studio.</p>
  
  <p>The insert statement I do within a <code>SqlTransaction</code>. The <code>Select IDENT_CURRENT('tableName')</code> is done after the transaction.</p>
  
  <p>What do I wrong?</p>
  
  <p><strong>UPDATE</strong>:</p>
  
  <p>My insert statement which is dynamically build together by a base class:</p>
  
  <pre><code>INSERT INTO TEST (NAME) VALUES (@Name)
  </code></pre>
  
  <p>The command's Parameter collection has the value "xxx" and everything is fine inserted into the table.</p>
  
  <p>I do NOT use stored procedures just pure <code>SqlDataReader</code> with C#.</p>
  
  <pre><code>commandText = "INSERT INTO TEST (NAME) VALUES ('Test1');Select Scopy_Identity();"
  </code></pre>
  
  <p>How can I get the last auto inc id running the above statement and should I call <code>ExecuteNonQuery</code> or <code>ExecuteReader</code> for the above because it has a <code>INSERT</code> and <code>SELECT</code> that's confusing...</p>