BD - obtener último registro



   AUTOR PREGUNTA

Publicado 16 junio 2014 - 20:21

¿Cómo puedo obtener el último item registrado en mi Base de Datos?


¿Tienes la misma pregunta? Yo también

 

Publicado 17 junio 2014 - 05:03

Debes usar un MAX en tu Select, de esta forma estarías obteniendo el mayor ID que es el último valor que se insertó:

  SELECT
   MAX(Id) as Id,
   BatchRef,
   ItemCount
  FROM HistoryTable
  WHERE
   BacthRef = @batchRef
  GROUP BY
   BatchRef,
   ItemCount

   AUTOR PREGUNTA

Publicado 17 junio 2014 - 14:28

Gracias jhony