title: Why is @@Identity returning null?
body: <p>I have a .NET 2010 app hitting a SQL2000 db. The code is pretty basic. When I insert a record, the record is inserted, but the id is not returned. The id column is an int and it is an Idetity. Here is the stored proc...</p>
  
  <pre><code>ALTER PROCEDURE Insert_Vendor
  
  @CorpID as varchar(255), 
  @TaxpayerID as varchar(255)
  AS
  
  Insert into  dbo.Vendor
  (
  vdr_CorpID, 
  vdr_TaxpayerID
  )
  values
  (
  @CorpID, 
  @TaxpayerID
  )
  
          IF @@error &lt;&gt; 0 
              BEGIN
                  RETURN -1
              END
          ELSE 
          RETURN @@Identity
  GO
  </code></pre>
  
  <p>And on the receiving end...</p>
  
  <pre><code> int myID = (int)(db.ExecuteScalar(dbCommand));
  </code></pre>