In an MSSQL database, I have automatically increasing IDs for every entry. Is it safe to acquire the ID of the newly inserted entry like this? I am worried that, if at the exact same time another entry gets inserted, I could end up with the wrong ID. string query = "INSERT INTO subscriptions (polygon,...) VALUES (@polygon,...)"; SqlDataAdapter cmd = new SqlDataAdapter(); using (SqlCommand querySaveSubscription = new SqlCommand(query)) { querySaveSubscription.Connection = openCon; // Create Poly out of given geodata values var point = SqlGeography.Point(Double.Parse(lat), Double.Parse(lon), 4326); SqlGeography poly = point.BufferWithTolerance(Double.Parse(radius) * 1000, 0.01, true); var param = new SqlParameter(@"polygon", poly); param.UdtTypeName = "Geography"; querySaveSubscription.Parameters.Add(param); ... openCon.Open(); querySaveSubscription.ExecuteNonQuery(); I have the following c# code directly after my INSERT INTO - query getting executed: query = "SELECT ID FROM subscriptions ORDER BY ID DESC"; SqlCommand command = new SqlCommand(query, openCon); SqlDataReader reader = command.ExecuteReader(); reader.Read(); int id = reader.GetInt32(0); result.Add("success", "true"); result.Add("id", id.ToString());