Hi,
you can get last Inserted Auto Value using below query
SELECT IDENT_CURRENT(‘tablename’)
It returns the last IDENTITY value produced in a table,
regardless of the connection that created the value, and regardless of
the scope of the statement that produced the value.
IDENT_CURRENT is not limited by scope and session; it is
limited to a specified table. IDENT_CURRENT returns the identity value
generated for a specific table in any session and any scope.
thanks
C# Code to get last Inserted AutoIncrement Value
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Connection String");
con.Open();
SqlCommand comm = new SqlCommand("select IDENT_CURRENT('table1')", con);
int currentAutoIncrementValue = Convert.ToInt32(comm.ExecuteScalar());
con.Close();
/* Do Anything With value */
}
Hope this will help you